Skip to main content

Module apidoc

Module apidoc 

Source
Expand description

API documentation: a generated OpenAPI 3 spec plus a RapiDoc browser page, both built by rocket_okapi directly from the #[openapi]-annotated agent routes — the spec is generated from the single source of truth (the real Rocket route + its return type) and so can never drift from the served API. This is the symmetry contract extended to the docs (see docs/archive/api-spike/COMPARISON.md + OPEN_QUESTIONS #7; rocket_okapi was chosen over utoipa).

Adding an endpoint to the docs is two steps: put #[openapi(tag = "…")] above its #[get/post/…] attribute, and list its handler in the [openapi_get_routes_spec!] call in mount. The DTOs it returns must derive schemars::JsonSchema.

Functions§

mount
Mounts the generated agent-API documentation onto rocket:
spec_json
The generated OpenAPI 3 document as pretty-printed JSON — the same bytes served live at GET /api/openapi.json, but obtainable without a running server or database (the spec is built purely from the route definitions). This is what cortex openapi prints and what the published docs site (scripts/build-docs-site.sh) bundles, so the static docs stay in lock-step with the served API.