
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
This was inspired by fastapi_versioning.
This project addresses issues with fastapi_versioning
and adds some additional features.
pip install fastapi-versionizer
You can find examples in the examples directory.
FastAPI Versionizer makes API versioning easy.
Here is a simple (and rather contrived) example:
from typing import List
from fastapi import FastAPI, APIRouter
from pydantic import BaseModel
from fastapi_versionizer.versionizer import Versionizer, api_version
class User(BaseModel):
id: int
name: str
class UserV2(BaseModel):
id: int
name: str
age: int
db = {
'users': {}
}
app = FastAPI(
title='test',
redoc_url=None
)
users_router = APIRouter(
prefix='/users',
tags=['Users']
)
@app.get('/status', tags=['Status'])
def get_status() -> str:
return 'Ok'
@api_version(1)
@users_router.get('', deprecated=True)
def get_users() -> List[User]:
return list(user for user in db['users'].values() if isinstance(user, User))
@api_version(1)
@users_router.post('', deprecated=True)
def create_user(user: User) -> User:
db['users'][user.id] = user
return user
@api_version(2)
@users_router.get('')
def get_users_v2() -> List[UserV2]:
return list(user for user in db['users'].values() if isinstance(user, UserV2))
@api_version(2)
@users_router.post('')
def create_user_v2(user: UserV2) -> UserV2:
db['users'][user.id] = user
return user
app.include_router(users_router)
versions = Versionizer(
app=app,
prefix_format='/v{major}',
semantic_version_format='{major}',
latest_prefix='/latest',
sort_routes=True
).versionize()
This will generate the following endpoints:
FastAPI Versionizer works by modifying a FastAPI app in place, adding versioned routes and proper docs pages.
Routes are annotated with version information, using the @api_version
decorator.
Using this decorator, you can specify the version (major and/or minor) that the route was introduced.
You can also specify the first version when the route should be considered deprecated or even removed.
Each new version will include all routes from previous versions that have not been overridden or marked for removal.
An APIRouter will be created for each version, with the URL prefix defined by the prefix_format
parameter described below,
docs_url
and redoc_url
.
swagger_ui_parameters
include_main_docs
and include_version_docs
to Falseinclude_main_openapi_route
and include_version_openapi_route
to False if you need to customize the OpenAPI schema.callback
param to Versionizer
and add your own docs/OpenAPI routes manually for each versionVersionizer.versionize()
.FAQs
API versionizer for FastAPI web applications
We found that fastapi-versionizer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.