Open qmffkem opened 2 years ago
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.
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!
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:
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.