diff --git a/integration/test/Test/Swagger.hs b/integration/test/Test/Swagger.hs index a84fc7b5419..7175e5d12f3 100644 --- a/integration/test/Test/Swagger.hs +++ b/integration/test/Test/Swagger.hs @@ -7,6 +7,8 @@ import Data.String.Conversions import GHC.Stack import System.Exit import System.FilePath +import System.IO (writeFile) +import System.IO.Temp (createTempDirectory) import System.Process import Testlib.Assertions import Testlib.Prelude @@ -127,3 +129,21 @@ testSwaggerLint sw = do liftIO $ putStrLn out liftIO $ putStrLn err assertFailure "swagger validation errors" + +testRenderAllSwaggers :: (HasCallStack) => App () +testRenderAllSwaggers = do + tempdir <- liftIO $ createTempDirectory "/tmp/" "wire-swagger-versions" + putStrLn $ "testRenderAllSwaggers: writing to " <> tempdir + let writeSwagger :: String -> Response -> App () + writeSwagger filename resp = do + content <- show <$> resp.json + liftIO $ writeFile (tempdir filename <> ".json") content + + for_ existingVersions $ \v -> do + bindResponse (BrigP.getSwaggerPublicAllJson v) $ \resp -> do + resp.status `shouldMatchInt` 200 + writeSwagger (show v) resp + for_ (Set.toList internalApis) $ \a -> do + bindResponse (BrigP.getSwaggerInternalJson a) $ \resp -> do + resp.status `shouldMatchInt` 200 + writeSwagger a resp