servant-swagger-ui-jensoleg-0.3.3: Servant swagger ui: Jens-Ole Graulund theme

Copyright(C) 2016-2018 Oleg Grenrus
MaintainerOleg Grenrus <>
Safe HaskellNone




Provides SwaggerUI and corresponding jensolegSwaggerSchemaUIServer to embed Jens-Ole Graulund themed swagger ui into the application.

All of the UI files are embedded into the binary.

An example:

-- | Actual API.
type BasicAPI = Get '[PlainText, JSON] Text
    :<|> "cat" :> Capture ":name" CatName :> Get '[JSON] Cat

-- | API type with bells and whistles, i.e. schema file and swagger-ui.
type API = SwaggerSchemaUI "swagger-ui" "swagger.json"
    :<|> BasicAPI

-- | Servant server for an API
server :: Server API
server = jensolegwaggerSchemaUIServer swaggerDoc
    :<|> (pure "Hello World" :<|> catEndpoint)
    catEndpoint name = pure $ Cat name False

Swagger UI API

type SwaggerSchemaUI (dir :: Symbol) (schema :: Symbol) = SwaggerSchemaUI' dir (schema :> Get (JSON ': ([] :: [Type])) Swagger) #

Swagger schema + ui api.

SwaggerSchemaUI "swagger-ui" "swagger.json" will result into following hierarchy:


type SwaggerSchemaUI' (dir :: Symbol) api = api :<|> (dir :> (Get (HTML ': ([] :: [Type])) (SwaggerUiHtml dir api) :<|> (("index.html" :> Get (HTML ': ([] :: [Type])) (SwaggerUiHtml dir api)) :<|> Raw))) #

Use SwaggerSchemaUI' when you need even more control over where swagger.json is served (e.g. subdirectory).

jensolegSwaggerSchemaUIServer :: Server api ~ Handler Swagger => Swagger -> Server (SwaggerSchemaUI' dir api) Source #

Serve alternative Swagger UI.

Current version: 79f3bba07b070cfab1d8c245c4f9229052e20a1a


jensolegSwaggerSchemaUIServer' :: Server api -> Server (SwaggerSchemaUI' dir api) Source #

Use a custom server to serve the Swagger spec source.

ReDoc theme