I guys, I'm trying to implement the Servant-Swagger UI. I use this example: However, I use a special monad for my Server with ReaderT: type App = ReaderT AppConfig Servant.Handler type API =AppAPI :<|> SwaggerSchemaUI "swagger-ui" "swagger.json" type AppAPI = .... server :: ServerT API App server = server' :<|> (swaggerSchemaUIServer swaggerDoc) server' :: ServerT AppAPI App server' = .... So how should I lift swaggerSchemaUIServer to my new monad? This is the function definition: swaggerSchemaUIServer :: Server api ~ Handler Swagger => Swagger -> Server (SwaggerSchemaUI' dir api) Thanks a lot! Corentin |
BTW: do you advice to use Swagger UI or simply Swagger markdown docs? On Mon, Nov 19, 2018 at 3:18 PM Corentin Dupont <[hidden email]> wrote:
|
In reply to this post by Corentin Dupont
I found this solution: type App = ReaderT AppConfig Servant.Handler type API = AppAPI :<|> AppDocs type AppDocs = SwaggerSchemaUI "swagger-ui" "swagger.json" type AppAPI = .... server :: ServerT API App server = serverApp :<|> serverDocs serverApp :: ServerT AppAPI App serverApp = ... serverDocs :: ServerT AppDocs App serverDocs = hoistDocs $ swaggerSchemaUIServer swaggerDoc swaggerDoc :: S.Swagger swaggerDoc = toSwagger (Proxy :: Proxy AppAPI) & S.info . S.title .~ "App API" & S.info . S.version .~ "v2.0.0" & S.info . S.description ?~ "This is the API" docAPI :: Proxy AppDocs docAPI = Proxy hoistDocs :: ServerT AppDocs Servant.Handler -> ServerT AppDocs Waziup hoistDocs s = Servant.Server.hoistServer docAPI lift s On Mon, Nov 19, 2018 at 3:18 PM Corentin Dupont <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |