Appearance
FastAPI routes and path operation functions
Applies to: **/routes/**/*.py, **/api/routers/**/*.py
Checklist
- Path operation functions MUST stay thin: validate input, call one use case, map the output or error. Flag inline business policy, configuration resolution, provider or persistence calls, and raw provider/SDK payload returns.
- Route collaborators MUST come from the dependency container (
Annotatedaliases wired increate_app/bootstrap.py); flag route modules importing infrastructure concretes or constructing adapters inline. - Routers MUST be created through the version/tag factory (
create_api_router) and mounted with explicitprefix=andtags=; flag bareAPIRouter()construction or route declarations directly on the app object. - A response payload uses ONE mechanism — return-type annotation OR
response_model=, never both; flagdict/Anyreturns outside documented streaming routes. - Streaming endpoints go through the SDK adapter's encoder (
EventStreamResponse) withstatus_code=200and declared error parts; flag hand-built stream chunks. - Domain failures are raised as domain error types and translated once in this layer; routes declare the matching error model on each failure path.