alexschimpf / fastapi-versionizer

FastAPI Versionizer
MIT License
81 stars 13 forks source link

Versioned API route_class #9

Closed bostrt closed 1 year ago

bostrt commented 1 year ago

Hello! We would like to be able to create an APIRouter using the route_class similar to what fastapi-versioning supports with versioned_api_route: https://github.com/DeanWay/fastapi-versioning/blob/18d480f5bb067088f157f235a673cb4c65ec77d5/fastapi_versioning/routing.py For example:

router = APIRouter(
    prefix="/myroute",
    tags=["MyRoute"],
    route_class=versioned_api_route(1, 1)
)

app.include_router(router)
versionize(app, ...)

Our local testing shows that dropping in versioned_api_route works okay with fastapi-versionizer but wanted to open an issue to see if you would want an PR opened for something like this or if you intend to keep @api_version the primary interaction.

alexschimpf commented 1 year ago

@bostrt Just added this for you here and pushed 0.1.6 to PyPI.

I also added an example file and accompanying tests.

Let me know if you see any problems with this.

bostrt commented 1 year ago

@alexschimpf thanks! I just tested it and works great :smiley: