| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Arbiter.Servant.OpenApi
Description
OpenAPI 3 description of ArbiterAPI. The route types
define paths, methods, parameters, bodies, success responses, and the declared
error responses. RegistryToAPI expands to the server route tree and includes
each queue by its registry name with its payload and result schemas.
Each payload and result type requires a ToSchema instance. For generic JSON, use
deriving anyclass (ToSchema). This module defines a Value
instance for free-form payloads.
Synopsis
- openApiSpec :: forall (registry :: JobPayloadRegistry). HasOpenApi (ArbiterAPI registry) => Text -> Value
- type OpenApiAPI = "openapi.json" :> Get '[JSON] Value
- openApiServer :: forall (registry :: JobPayloadRegistry). HasOpenApi (ArbiterAPI registry) => Text -> Server OpenApiAPI
The document
openApiSpec :: forall (registry :: JobPayloadRegistry). HasOpenApi (ArbiterAPI registry) => Text -> ValueSource #
The description of a registry's API, from its route types. The version
goes to info.version. The document also describes the registry's queues
and payloads, so the caller owns its version.
Serving it
type OpenApiAPI = "openapi.json" :> Get '[JSON] ValueSource #
The document's own route, for mounting beside ArbiterAPI.
Mount it before Arbiter.Servant.UI.AdminUI. That route is a Raw catch-all.
Give the registry by type application and the document version as an argument:
type MyApp = ArbiterAPI MyRegistry :<|> OpenApiAPI :<|> AdminUI run port $ serve (Proxy @MyApp) (arbiterServer config :<|> openApiServer @MyRegistry "1.0.0" :<|> adminUIServer)
openApiServer :: forall (registry :: JobPayloadRegistry). HasOpenApi (ArbiterAPI registry) => Text -> Server OpenApiAPISource #
Serve the description of a registry's API at a given document version.