fastapi
Building HTTP APIs with FastAPI and Pydantic.
-
Enforcing Client Identity Alongside Realm Roles
Keycloak azp claim: a realm role does not show which client the token was issued to. Enforcing azp next to role checks in a FastAPI dependency.
-
An OpenAI-Compatible Proxy in Front of a Local Model Server
/v1/chat/completions behind a FastAPI proxy: bearer API-key auth, unbuffered SSE streaming, and a /healthz that cannot trigger a model load.
-
One Dashboard on Five Unrelated Backends: Normalising at the Boundary
asyncio.gather with return_exceptions=True in a FastAPI BFF: map two upstream APIs onto one schema and return partial data with health when one is down.
-
Closed-Vocabulary Pydantic Validation for a Public Ingest Endpoint
Pydantic extra="forbid" and Literal types return 422 for typo'd fields and unknown values that the default extra="ignore" silently drops.
-
An Exception Hierarchy and One Handler for FastAPI Error Responses
FastAPI add_exception_handler on a base AppError instead of raising HTTPException in services: one status-code mapping and a consistent error body.
-
Designing a Consistent FastAPI Response Envelope
FastAPI response envelope with Pydantic Generic[T] and a custom APIRoute get_route_handler that wraps every response in success, data and error.
-
A Feature-Module Layout for a FastAPI Application That Keeps Growing
FastAPI APIRouter per feature directory with its own router.py, schemas.py and service.py, replacing a shared routers.py, schemas.py and crud.py.