http
Routing plumbing shared by the patient-data API's domains.
What a domain's router needs from the layers below it: the route class that reports query parameters a handler does not accept, the parameter annotations and the response fragments the routes document themselves with, and the descriptions of the two parameters every paginated route takes.
The shared annotations and descriptions live here rather than in each domain so the same parameter cannot be described two ways in the published document.
Every parameter states its description and its constraints on the Query/Path
marker, not only in the handler docstring. FastAPI publishes each marker as the
parameter's own description, so that is the only spelling a consumer of the
document sees against the parameter — and a constraint enforced only inside the
handler documents the endpoint as accepting values it rejects.
A handler docstring is not a second place to document a parameter. FastAPI
takes the whole docstring as the operation's description, so an Args: block
is published verbatim, including the entries for Depends-injected arguments a
client never sends. build_openapi trims each description to its caller-facing
prose for that reason; see _endpoint_description.
Module
Functions
api_router
def api_router() ‑> fastapi.routing.APIRouter:Build a router for one domain of the API.
Every router is built here so the API's routing behaviour — today, the warning for query parameters a handler does not accept — is decided in one place rather than repeated per domain.
Returns A router carrying the API's route class.
not_found
def not_found(description: str, *examples: str) ‑> dict[str, typing.Any]:An OpenAPI 404 entry carrying the handler's real detail strings.
Arguments
description: What a404means for the route.examples: The exactdetailvalues the handler raises, in the order they should be offered.
Returns The OpenAPI response object.