Added
- Dependency Injection system with
DependsandSecurityfor automatic dependency resolution- Request-scoped caching (same dependency called multiple times returns cached result)
- Circular dependency detection
SecurityScopesinjection for OAuth2 scope validation- Generator/yield dependencies with proper cleanup (sync and async)
- FastAPI-style parameter classes:
Query,Path,Header,Cookie,Body,Form,File- Full Pydantic v2 validation:
gt,ge,lt,le,min_length,max_length,pattern,multiple_of,strict, etc. - Parameter metadata:
description,title,example,examples,deprecated - Alias support for headers and query parameters
- Full Pydantic v2 validation:
- Django support with
DjangoRouter(sync) andDjangoAsyncRouter(async), includingurlsproperty for Django URL patterns - Falcon async support with
FalconAsyncRouter(in addition to existing syncFalconRouter) FileUploadclass for framework-agnostic file handling with.read()and.aread()methods- Form data and file upload extraction for all frameworks
RequestDataunified container for request data across all frameworksResponseclass for custom responses with headers and status codes- Response model validation via
TypeAdapterwith thread-safe caching - Standardized error hierarchy:
APIError,BadRequestError,ValidationError(422),AuthenticationError,AuthorizationError,ResourceNotFoundError,ResourceConflictError,InternalServerError,ServiceUnavailableError,DependencyError,CircularDependencyError,SecurityError APIError.from_exception()for converting any exception to standardized JSON formatEXCEPTION_MAPPERon routers for framework-specific exception conversion (e.g., Django'sPermissionDenied→AuthorizationError)- Built-in OpenAPI security schemes: Bearer JWT, API Key (header/query), Basic Auth, OAuth2
- Custom security schemes via
security_schemeparameter (acceptsSecuritySchemeTypeenum or raw dict) - Security scheme merging in
include_router() SecuritySchemeTypeexported fromfastopenapifor public use- Documentation completely rewritten with guides, API reference, framework-specific pages, and examples
Changed
- Complete architecture refactor from monolithic
base_router.pyto composition-based modular design:core/—BaseRouter, parameter classes, dependency resolver, types, constantsresolution/—ParameterResolver(extracted fromBaseRouter.resolve_endpoint_params())response/—ResponseBuilder(extracted fromBaseRouter._serialize_response())openapi/—OpenAPIGenerator,SchemaBuilder, UI renderers (extracted fromBaseRouter.generate_openapi())errors/— error hierarchy (extracted fromerror_handler.py)routers/—BaseAdapter+ per-framework packages with separate extractors
- All framework routers now inherit from
BaseAdapterinstead ofBaseRouter - Each framework router split into separate router and extractor modules
- Route metadata stored in
RouteInfoclass (was tuple) - Validation errors now return HTTP 422 (was 400)
- OpenAPI
summaryresolved from route metadata or formatted endpoint name;descriptionfrom metadata or docstring - Improved import errors with
MissingRouterraisingImportErrorwhen framework is not installed djangoadded as optional dependency extra
Deprecated
- Importing from
fastopenapi.error_handlermodule (usefrom fastopenapi.errors import ...instead)
Removed
BaseRouter.generate_openapi()method (userouter.openapiproperty)BaseRouter.resolve_endpoint_params()andBaseRouter._serialize_response()internal methods- Multi-language documentation (single English version retained)