flare_mlake · API · openapi

flare.openapi.from_router

Derive an :class:OpenApiSpec from a runtime :class:Router.

Walks the router's registered route table -- method + path template + path-parameter names -- and builds a spec whose paths group by template with one operation per method. Path parameters (:name segments) surface as required path parameters; every operation gets a default 200 response.

ponytail: this derives the structural surface the runtime Router retains (methods, path templates, path params). Request/response body schemas and query/header parameters live on the typed Extracted[H] handler, which the Router erases at registration -- deriving those needs a comptime walk of reflect[H] at the registration site (the ComptimeRouter path), not runtime introspection. Mounted sub-routers are not walked yet (top-level routes only).

Functions

spec_from_router

def spec_from_router(r: Router, title: String, version: String) -> OpenApiSpec

Build an :class:OpenApiSpec from r's registered routes.

Operations under the same template are merged into one :class:OpenApiPath; first-seen template order is preserved so the emitted JSON is deterministic.