mirror of
https://github.com/aelve/guide.git
synced 2024-12-22 20:31:31 +03:00
Serve both swaggers
This commit is contained in:
parent
cdc4bd74fe
commit
a68e1f1506
@ -143,6 +143,7 @@ library
|
||||
, servant
|
||||
, servant-server
|
||||
, servant-swagger
|
||||
, servant-swagger-ui
|
||||
, servant-swagger-ui-redoc
|
||||
, swagger2
|
||||
, shortcut-links >= 0.4.2
|
||||
|
@ -17,6 +17,7 @@ import Servant
|
||||
import Servant.API.Generic
|
||||
import Servant.Server.Generic
|
||||
import Servant.Swagger
|
||||
import Servant.Swagger.UI
|
||||
import Servant.Swagger.UI.ReDoc
|
||||
import Data.Swagger.Lens
|
||||
import Network.Wai.Handler.Warp (run)
|
||||
@ -52,14 +53,18 @@ apiServer db = Site
|
||||
|
||||
type FullApi =
|
||||
Api :<|>
|
||||
SwaggerSchemaUI "api" "swagger.json"
|
||||
SwaggerSchemaUI "api" "swagger.json" :<|>
|
||||
SwaggerSchemaUI "try" "swagger.json"
|
||||
|
||||
fullServer :: DB -> Server FullApi
|
||||
fullServer db =
|
||||
toServant (apiServer db) :<|>
|
||||
redocSchemaUIServer (toSwagger (Proxy @Api)
|
||||
& info.title .~ "Aelve Guide API"
|
||||
& info.version .~ "alpha")
|
||||
redocSchemaUIServer doc :<|>
|
||||
swaggerSchemaUIServer doc
|
||||
where
|
||||
doc = toSwagger (Proxy @Api)
|
||||
& info.title .~ "Aelve Guide API"
|
||||
& info.version .~ "alpha"
|
||||
|
||||
-- | Serve the API on port 4400.
|
||||
--
|
||||
@ -77,5 +82,7 @@ runApiServer db = do
|
||||
-- to list of `corsOrigins` to allow CORS requests
|
||||
{ corsOrigins = Just ([ "http://localhost:3333"
|
||||
-- ^ Guide's frontend running on localhost
|
||||
, "http://localhost:4400"
|
||||
-- ^ The /try endpoint of the API
|
||||
], True)
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ extra-deps:
|
||||
- cmark-sections-0.3.0.1
|
||||
- acid-state-0.14.3
|
||||
- servant-swagger-ui-redoc-0.3.0.1.21.2
|
||||
- servant-swagger-ui-0.3.0.3.13.2
|
||||
- file-embed-lzma-0
|
||||
- servant-0.14.1
|
||||
- servant-swagger-1.1.5
|
||||
|
Loading…
Reference in New Issue
Block a user