We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I couldn't find a function for this:
-- | Dump the swagger schema and swagger-ui files to a directory. swaggerSchemaUiDump :: forall dir api schema . (KnownSymbol dir, KnownSymbol schema, Servant.HasSwagger api) => FilePath -- ^ directory in which to write -> Proxy (Servant.SwaggerSchemaUI dir schema) -> Proxy api -> IO () swaggerSchemaUiDump outDir Proxy p = do let dir = symbolVal @dir Proxy schema = symbolVal @schema Proxy index = T.encodeUtf8 $ T.replace "SERVANT_SWAGGER_UI_SCHEMA" (T.pack schema) $ T.replace "SERVANT_SWAGGER_UI_DIR" (T.pack dir) $ Servant.swaggerUiIndexTemplate swagger = Servant.toSwagger p -- The paths are prepended with '/' which confuses </> uiFiles = first (dropWhile (== '/')) <$> Servant.swaggerUiFiles prefix = case dir of "" -> outDir _ -> outDir </> dir let allFiles = [(outDir </> schema, BL.toStrict $ Aeson.encode swagger)] <> [(prefix </> "index.html", index)] <> (first (prefix </>) <$> uiFiles) forM_ allFiles $ \(path, content) -> do Directory.createDirectoryIfMissing True (FilePath.takeDirectory path) BS.writeFile path content
Happy to open a PR if you think this'll be useful to others.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I couldn't find a function for this:
Happy to open a PR if you think this'll be useful to others.
The text was updated successfully, but these errors were encountered: