alexschimpf / fastapi-versionizer

FastAPI Versionizer
MIT License
79 stars 13 forks source link

include_route using api version #61

Closed lcsvcn closed 6 months ago

lcsvcn commented 6 months ago

Is it possible to do something like this?

@api_version(1, remove_in_major=2)
app.include_router(
    user_v1_route, prefix="/user", tags=["user"]
)

@api_version(2)
app.include_router(
    user_v2_route, prefix="/user", tags=["user"]
)
alexschimpf commented 6 months ago

This seems pretty similar to the other issue you opened: https://github.com/alexschimpf/fastapi-versionizer/issues/51

As for this specific question... decorators can only be applied to function or class definitions. So this would not work in Python.