Openapi Intregation
Generating API documentation from your controllers.
Avleon generates an OpenAPI document from your controllers and serves a browsable UI. Nothing extra to install — the Swagger integration ships with the core.
Enabling
The UI is then served at routePrefix — http://localhost:4000/docs above.
useOpenApi also accepts a plain options object if you do not need a config
class:
Options
| Option | Description |
|---|---|
info | Title, version, description |
routePrefix | Where the UI is served. Defaults to /docs |
provider | 'default' (Swagger UI) or 'scalar' |
servers | Server URLs |
tags | Tag definitions |
security | Global security requirements |
components | Reusable schemas and security schemes |
Scalar UI
To use Scalar instead of Swagger UI, set the provider — it ships with the core, so there is nothing extra to install:
The CLI can wire this up for you — pick Scalar UI when running avleon new.
Documenting routes
Use @OpenApi on a controller or a route method to enrich the generated
document.
Useful @OpenApi fields:
| Field | Description |
|---|---|
summary / description | Human-readable text |
tags | Groups the route in the UI |
params / query / headers | Document inputs |
requestBody | Document the body |
response | Responses keyed by status code |
deprecated | Mark the route deprecated |
exclude | Hide the route from the document |
security | Per-route security requirements |
For example, documenting inputs:
Inline routes
Routes registered with mapGet and friends return a chainable object, so they
can carry their own OpenAPI metadata:
The same object also exposes useMiddleware: