Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router with versioning #58

Open
itomtom opened this issue Sep 8, 2021 · 1 comment
Open

Router with versioning #58

itomtom opened this issue Sep 8, 2021 · 1 comment

Comments

@itomtom
Copy link

itomtom commented Sep 8, 2021

Is your feature request related to a problem? Please describe.
Currently from the examples I've seen to have versioning on multiple router you need to proceed as such. Where you will need to create different router and append the versioning numbers yourself without using the @version decorator. Is there a more clear cut way to do this without creating different routers and use the version decorator

Describe the solution you'd like
I would like to be able to version my routers similar to the examples in the README, so something like:

from fastapi import APIRouter
from fastapi_versioning import VersionedFastAPI, version

router = APIRouter(
    prefix="/greetings",
    tags=["greetings"],
)

@router.get("/hello")
@version(1)
def greet_with_hello():
    return "Hello"


@router.get("/hello")
@version(2)
def greet_with_hi():
    return "Hi"

router= VersionedFastAPI(router)

Describe alternatives you've considered
I can proceed with the example listed in Issue 34. However, manually adding the version number to the url is something I would like to avoid.

Additional context

@den4uk
Copy link

den4uk commented Sep 7, 2022

I also found myself here, nearly wanting to write exactly the same issue as @itomtom.
Versioning of a APIRouter makes a lot more sense, then a whole instance of FastAPI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants