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

remove "latest" keyword from url path for the latest version API? #67

Open
JaeungJayJang opened this issue Mar 11, 2022 · 2 comments
Open

Comments

@JaeungJayJang
Copy link

JaeungJayJang commented Mar 11, 2022

Is your feature request related to a problem? Please describe.
This is a question regarding #35.
I am curious about why you would want the keyword "latest" to be in the path, because it feels more natural that /api/endpoint serve the latest version of the API by default.

Describe the solution you'd like
If that is clear, i guess we can remove the keyword "latest" from the prefix in versioning.py, line 76, so anything from the default API direct to the latest API.
Reference source code link:

modification:

if enable_latest:
        prefix = "/"
......

Alternative option
The above question is actually from the concern whether I could set some version of API to be a generic API like...
suppose you have v1, v2, and v3 APIs where all have /items endpoint, and you want v2 to be accessible by default path like /items ( /items redirect to /v2/items )

Additional context
I would mainly want to know the decision behind the usage of the keyword; #35 describes the reason, but it's not really convincing to me and if the concern here is about serving the latest version to client, generic API call without any version, keyword, etc would be better for users and also for restfulness too.

@elongstreet88
Copy link

So i've been looking at this as well.
I think a better option would be to pass a "latest_prefix" as an argument or just simply honor the prefix when provided.

My issue currently is:

# Register Routes
app.include_router(home_router)
app.include_router(user_router_v1)

# Versioned API
app = VersionedFastAPI(
    app, 
    enable_latest=True,
    prefix_format="/api/v{major}"
)

# /api/v1/docs -> Works
# /api/latest/docs -> Doesn't Work
# /docs -> Works
# /api/docs -> Doesn't work

I would like /api/v1 and /api/latest to be at the same stub, if that makes sense.

@brandonwreich
Copy link

This would be amazing if we could get this (pull request #68) merged so that you don't need to specify a version every time you call an endpoint!

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

3 participants