API versioning library for FastAPI applications with decorator-based version management and automatic endpoint generation.
FastAPI Versioning is a Python library that adds API versioning capabilities to FastAPI web applications. It provides decorator-based version management that automatically creates versioned endpoints and documentation, helping developers maintain backward compatibility while evolving their APIs.
Backend developers building REST APIs with FastAPI who need to maintain multiple API versions for backward compatibility and gradual migration.
It offers a clean, intuitive way to version FastAPI endpoints without manual route duplication, with automatic generation of versioned OpenAPI documentation and optional latest-version redirect endpoints.
api versioning for fastapi web applications
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The @version decorator allows easy marking of endpoints with version numbers, as shown in examples like @version(1, 0) for clean, readable code.
Separate OpenAPI docs and Swagger UI are created for each API version, evidenced by endpoints such as /v1_0/docs and /v1_0/openapi.json in the README.
Optional /latest endpoints can be enabled with enable_latest=True, automatically pointing to the most recent API version for simplified client access.
Supports both major-only and major-minor versioning schemes with customizable prefixes, as demonstrated in the usage without minor version example.
Middleware, event handlers, and other FastAPI constructor arguments must be manually passed to VersionedFastAPI, adding complexity and risk of errors, as highlighted in the README's extra constructor arguments section.
Only supports major and minor versions; there's no built-in handling for patch versions or more nuanced semantic versioning, which might be restrictive for some APIs.
Automatic generation of versioned endpoints can lead to a proliferation of routes (e.g., /v1_0/greet, /v1_1/greet), which might complicate debugging and maintenance in large applications.