Skip to content
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

added support and tests for pydantic dataclasses #454

Merged
merged 2 commits into from
Aug 30, 2019

Conversation

dconathan
Copy link
Contributor

Fixes #265

Summary of changes:

  • in fastapi.utils.create_cloned_field we coerce a pydantic dataclass to its BaseModel version using the __pydantic_model__ attribute
  • changed the test_serialize_response.py test to actually test serializing the response and created a separate test test_validate_response.py which tests for appropriate ValidationErrors
  • created *_dataclass.py variants of test_serialize_response and test_validate_resonse

@codecov
Copy link

codecov bot commented Aug 30, 2019

Codecov Report

Merging #454 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #454    +/-   ##
======================================
  Coverage     100%   100%            
======================================
  Files         240    251    +11     
  Lines        5626   5868   +242     
======================================
+ Hits         5626   5868   +242
Impacted Files Coverage Δ
tests/test_serialize_response.py 100% <100%> (ø) ⬆️
tests/test_validate_response.py 100% <100%> (ø)
tests/test_validate_response_dataclass.py 100% <100%> (ø)
tests/test_serialize_response_dataclass.py 100% <100%> (ø)
fastapi/utils.py 100% <100%> (ø) ⬆️
tests/test_additional_responses_router.py 100% <0%> (ø) ⬆️
fastapi/dependencies/utils.py 100% <0%> (ø) ⬆️
fastapi/openapi/utils.py 100% <0%> (ø) ⬆️
fastapi/routing.py 100% <0%> (ø) ⬆️
fastapi/openapi/models.py 100% <0%> (ø) ⬆️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 033bc2a...a75dffe. Read the comment docs.

@tiangolo tiangolo merged commit 3025a36 into tiangolo:master Aug 30, 2019
@tiangolo
Copy link
Owner

Great! Thanks a lot! 🚀 🍰

@manojlds
Copy link

manojlds commented Sep 3, 2019

Is this available for use?

@zamiramir
Copy link
Contributor

Is this available for use?

Released with 0.37.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Pydantic's dataclasses
5 participants