- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
🐛 Fix edge case with repeated aliases names not shown in OpenAPI #2351
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2351 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 532 533 +1
Lines 13684 13701 +17
=========================================
+ Hits 13684 13701 +17
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
📝 Docs preview for commit 2078360926f56483db28a5a66c9fc9d1e610c8fc at: https://5fafc65b048ac31efbfc9ef8--fastapi.netlify.app |
2078360
to
8d5fc97
Compare
📝 Docs preview for commit 8d5fc97 at: https://5fafc9c1048ac31bf9fc9f69--fastapi.netlify.app |
maybe i'm a bit dense, but why do you need the same alias to a query and a path param? |
Thank you, the path param and query is a corner case indeed and easily solvable by just changing the name of the query param (which is an implementation detail). On the other hand, consider a combination of query/cookie/header parameter. I agree it can be a corner case, but it is not an implementation detail and may be a particular requirement for an API to expose |
📝 Docs preview for commit 329cc33 at: https://62fe9f757e6f0d007c146366--fastapi.netlify.app |
…tapi#2351) Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Currently, routes' parameters defined in multiple dependencies are not duplicated since only one parameter per position (path, query, headers, cookie) is retrieved. The current solution has the caveat of not identifying parameters with the same alias, but different position.
Problem example
Example of parameters shown in the current FastAPI Schema for the given route:
Solution
To fix the name clashing, it is sufficient to consider parameters duplicated only if they have the same alias and the same type.
The OpenAPI generated by the PR solution is: