use annotated description as Field description#9670
Closed
vincentsarago wants to merge 1 commit intofastapi:masterfrom
Closed
use annotated description as Field description#9670vincentsarago wants to merge 1 commit intofastapi:masterfrom
vincentsarago wants to merge 1 commit intofastapi:masterfrom
Conversation
vincentsarago
commented
Jun 13, 2023
|
|
||
| response = client.get("/test1/baz") | ||
| assert response.status_code == 200 | ||
| assert response.json() == {"foo": "baz"} |
Author
There was a problem hiding this comment.
This is kinda not related to the PR's goal but I felt it was important to have this test to make sure this feature (supporting optional path) is supported!
Member
|
📝 Docs preview for commit 60d163d at: https://648898509e9ccd2141608062--fastapi.netlify.app |
This was referenced Jun 13, 2023
Author
|
Is there anything I need to do here? 🙏 |
Contributor
|
This pull request has a merge conflict that needs to be resolved. |
Member
|
This could cause conflicts with a bunch of other behaviors. I'll need to handle this later in a different way. For now, I'll close this one. ☕ |
Member
|
This could cause conflicts with a bunch of other behaviors. I'll need to handle this later in a different way. For now, I'll close this one. ☕ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ref: #9278
History
Since FastAPI 0.95 we cannot have multiple endpoint routes with optional
Pathparameter (because we cannot mix the Query/Path for a variable: 375513f#r105161665), while it seems thisbreakingchange is assumed, I personally still need this feature.To solve this, I have to remove the usage of
Query/Pathclass and use simpleAnnotatedform, but this means that I loose the niceOpenAPIkwargs provided by FieldInfo.Proposed change
With this PR I'm proposing that we use the first metadata annotation as Field's description
in ☝️
"get a description"will be forwarded to the OpenAPI schema as field's description 👇I originally designed a more complex solution over #9289, but I think what I'm proposing with this PR is much more simple (thus acceptable ? 😅).