Swagger UI

13 views
Skip to first unread message

Corentin Dupont

unread,
Nov 19, 2018, 8:18:41 AM11/19/18
to haskell...@googlegroups.com
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

Corentin Dupont

unread,
Nov 19, 2018, 9:46:45 AM11/19/18
to haskell...@googlegroups.com
BTW: do you advice to use Swagger UI or simply Swagger markdown docs?

Corentin Dupont

unread,
Nov 20, 2018, 4:05:09 AM11/20/18
to haskell...@googlegroups.com
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 <corenti...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages