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

Fixing validator-caused incorrect output key order#637

Merged
tiangolo merged 3 commits intofastapi:masterfrom
jaddison:fix/issue-630
Nov 24, 2019
Merged

Fixing validator-caused incorrect output key order#637
tiangolo merged 3 commits intofastapi:masterfrom
jaddison:fix/issue-630

Conversation

@jaddison
Copy link
Contributor

@jaddisonjaddison commentedOct 21, 2019
edited
Loading

A quick PR thatfixes#630. The cloned field was adding existing field validators before the fields themselves.

This caused Python's default "ordereddict" behaviour to incorrectly output dictionary key/value pairs with all 'validated' fields first.

Fixesfastapi#630. The cloned field was added existing field validators before the fields themselves. This caused Python's default "ordered `dict`" behaviour to incorrectly output dictionary key/value pairs with all 'validated' fields first.
@dmontagu
Copy link
Collaborator

Have you confirmed that this doesn't change the validation logic? Probably worth making sure validators still work on endpoints with a response model (maybe this is already tested in the existing tests).

Pydantic has some metaprogramming magic that could mean the validators don't get set up properly if they aren't present during class initialization; I'm not sure.

Fixesfastapi#630. The cloned field was added existing field validators before the fields themselves.This caused Python's default "ordered `dict`" behaviour to incorrectly output dictionary key/value pairs with all 'validated' fields first.
@codecov
Copy link

codecovbot commentedOct 22, 2019
edited
Loading

Codecov Report

Merging#637 intomaster willnot change coverage.
The diff coverage is100%.

Impacted file tree graph

@@          Coverage Diff          @@##           master   #637   +/-   ##=====================================  Coverage     100%   100%           =====================================  Files         269    269             Lines        6823   6824    +1     =====================================+ Hits         6823   6824    +1
Impacted FilesCoverage Δ
fastapi/utils.py100% <100%> (ø)⬆️

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update65536cb...25540ed. Read thecomment docs.

@jaddison
Copy link
ContributorAuthor

Have you confirmed that this doesn't change the validation logic? Probably worth making sure validators still work on endpoints with a response model (maybe this is already tested in the existing tests).

Yes, all of the endpoints in my projects haveresponse_model parameters set, and all are functioning as expected. That said, I assume that package tests would find any bugs introduced in this regard? 🤔

Including 'reformatting' change introduced by `black`.
@dmontagu
Copy link
Collaborator

Looks good to me!

@tiangolotiangolo merged commit4e50f53 intofastapi:masterNov 24, 2019
@tiangolo
Copy link
Member

Great! Thank you@jaddison! 🚀 🍰

And thanks@dmontagu for the PR review, that's highly appreciated 💪 🌮

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@dmontagudmontagudmontagu left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

JSON output reordered by pydantic @validator

3 participants

@jaddison@dmontagu@tiangolo

[8]ページ先頭

©2009-2026 Movatter.jp