FastAPI Cheatsheet 01 — Routing, Path Operations, and Routers
Cheatsheet: GET/POST/etc decorators, path/query/body/header/cookie/form/file params, APIRouter, prefixes, dependencies on routers, and url_path_for.
Cheatsheet: GET/POST/etc decorators, path/query/body/header/cookie/form/file params, APIRouter, prefixes, dependencies on routers, and url_path_for.
FastAPI architecture: ASGI, Starlette, Pydantic, dependency injection, and the design choices that make it tick.
Cheatsheet: BaseModel, Field, validators, custom errors, nested, discriminated unions, strict mode at the boundary.
Path operations, parameter declaration (path / query / body / header / cookie / form / file), routers, prefixes, dependencies on routers, and request internals.
Cheatsheet: response_model, exclusion, custom encoders, JSON / HTML / Streaming / File responses, status codes, headers.
Request validation with Pydantic v2: BaseModel, Field, validators, custom types, error responses, nested models, discriminated unions, and the FastAPI integration.
Cheatsheet: Depends, yield-deps, sub-deps, class deps, security deps, dependency_overrides for tests, lifespan.
Output side of FastAPI: response_model, response shaping, custom encoders, status codes, response classes (JSON, HTML, Streaming, File).
Cheatsheet: argon2 hashing, OAuth2 password flow, refresh tokens, sessions, API keys, scopes, RBAC, resource-level authz.
Dependency injection in FastAPI: Depends, scopes, sub-deps, class-based deps, lifecycle (startup/shutdown), and the patterns from production.