Docs and HTTP fall out
Once the Api is bound, HTTP and OpenAPI are free.
val spec = api.openApi
val http = api.routes
spec.routes("docs") // Swagger UI at /docs, spec at /docs/openapi.json
There is no second source of truth. Content keys are charset-less (application/json).
Endpoint.auth(SecurityScheme.HttpBearer()) is what Swagger uses for Authorize.
OpenAPI · Try it out
GET/shows/{id}users
parameters
id · path · integer = 1
Execute runs GET /shows/1.
api.openApi.routes("docs") serves this. No second spec.
The spec is a projection
Api.openApi / OpenApi.from(...) render OpenAPI 3.1. This test reads the
JSON we serve, not a fixture we typed twice.
OpenAPI is a projection
/shows/{id}:
get:
summary: One bill
parameters: [{ name: id, in: path, schema: integer }]
responses:
"200": { schema: Show }
"404": { schema: NotFound }Try it on the live hub
sbt example/run
Open http://localhost:8080/docs.
GET /shows/1→ Evening bill.Authorize against the embedded OP (seed
ada/ada).POST /partieswith{"showId":1,"size":2}.
Swagger is a host of the same Api as GET /shows/1 in these tests. Execute above is the map.
The process is the territory.
Next
Agents fall out. Api.job is the extra mark.