Swagger UI

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Swagger UI

Corentin Dupont
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:



Thanks a lot!

Corentin

--
Reply | Threaded
Open this post in threaded view
|

Re: Swagger UI

Corentin Dupont
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:
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:



Thanks a lot!

Corentin

--
Reply | Threaded
Open this post in threaded view
|

Re: Swagger UI

Corentin Dupont
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:
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:



Thanks a lot!

Corentin

--