Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

🐛 Make sure a parameter defined as required is kept required in OpenAPI even if defined as optional in another dependency#4319

Merged
tiangolo merged 8 commits intofastapi:masterfrom
chardigio:enforce-once-required-parameter
Sep 3, 2022
Merged

🐛 Make sure a parameter defined as required is kept required in OpenAPI even if defined as optional in another dependency#4319
tiangolo merged 8 commits intofastapi:masterfrom
chardigio:enforce-once-required-parameter

Conversation

@chardigio
Copy link
Contributor

@chardigiochardigio commentedDec 21, 2021
edited
Loading

Summary
In the case where a parameter is looked for by multiple dependencies, but only required by some of them, we should reflect that in the openapi spec asrequired=True.

Currently
Right now the openapi spec indeterminately displays the parameter being required/optional. However, omitting the parameter will always result in a422.

Suggested
We ought not change anything about how the server acts, however we should show that the parameter is required in the openapi spec.

Rationale
As is, this is misleading and confusing for anyone trying to work with OpenAPI where this kind of situation arises. This becomes especially important when using inheritance withclass-based views. Often times you may want to look for a certain field in a base view, but only require it insome of the views that inherit from it.

Copy link
Contributor

@cikaycikay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The commit message should be "Simplify conditions"

@chardigio
Copy link
ContributorAuthor

@tiangolo any chance you can check this out? It would help clear up our docs a lot 🙏🏼

@tiangolotiangolo changed the titleEnforce once-required parameter🐛 Make sure a parameter defined as required is kept required in OpenAPI even if defined as optional in another dependencySep 3, 2022
@codecov
Copy link

codecovbot commentedSep 3, 2022
edited
Loading

Codecov Report

Merging#4319 (230cdcc) intomaster (fbe1a80) willnot change coverage.
The diff coverage is100.00%.

@@            Coverage Diff            @@##            master     #4319   +/-   ##=========================================  Coverage   100.00%   100.00%           =========================================  Files          538       539    +1       Lines        13872     13902   +30     =========================================+ Hits         13872     13902   +30
Impacted FilesCoverage Δ
fastapi/openapi/utils.py100.00% <100.00%> (ø)
tests/test_enforce_once_required_parameter.py100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell ushow you rate us. Have a feature suggestion?Share it here.

@tiangolo
Copy link
Member

Thanks for the contribution @cd17822! 🍰

I updated the test to have in mind the new schemas for validation errors. And I refactored the implementation to account for the location of parameters, from a recent PR.

Thanks for the interest here@cikay, nevertheless, it's not necessary to ask for some type of commit messages. I make sure the final commit message is consistent with the rest and then squash and merge. It's better to check if the implementation is correct, if it has tests, if the tests break before the fix and pass after the fix. Thanks!

This will be available in the next FastAPI version,0.82.0, probably in the next hours. 🎉

chardigio reacted with heart emoji

@github-actions
Copy link
Contributor

📝 Docs preview for commitbafa232 at:https://63137cf667cd57337c0f7914--fastapi.netlify.app

@tiangolotiangoloenabled auto-merge (squash)September 3, 2022 16:13
@github-actions
Copy link
Contributor

📝 Docs preview for commitd2e3ae3 at:https://63137f52ea02943531f61914--fastapi.netlify.app

@tiangolotiangolo merged commit56f887d intofastapi:masterSep 3, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@cikaycikaycikay left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@chardigio@tiangolo@cikay

[8]ページ先頭

©2009-2026 Movatter.jp