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

✨ Add support in jsonable_encoder for include and exclude with dataclasses #4923

Merged
merged 4 commits into from Sep 8, 2022

Conversation

DCsunset
Copy link
Contributor

@DCsunset DCsunset commented May 18, 2022

Originally if the object is a dataclass, jsonable_encoder won't respect the include and exclude arguments.
This PR fixes this issue by applying jsonable_encoder to the dict of the dataclass.

@codecov
Copy link

codecov bot commented May 18, 2022

Codecov Report

Merging #4923 (693c8a4) into master (895789b) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #4923   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          539       539           
  Lines        13906     13918   +12     
=========================================
+ Hits         13906     13918   +12     
Impacted Files Coverage Δ
fastapi/encoders.py 100.00% <ø> (ø)
tests/test_jsonable_encoder.py 100.00% <100.00%> (ø)

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

@github-actions
Copy link
Contributor

📝 Docs preview for commit d79c13d at: https://628452eb9fe1990e5473d258--fastapi.netlify.app

@tiangolo
Copy link
Owner

Thanks! Could you add a couple of tests for it? Probably in test_jsonable_encoder.py

@DCsunset
Copy link
Contributor Author

Sure. I'll add it when I have time.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2022

📝 Docs preview for commit ed92464 at: https://63151485063a093c68a88db5--fastapi.netlify.app

@tiangolo tiangolo changed the title 👷 Fix jsonable_encoder to respect include and exclude args ✨ Add support in jsonable_encoder for include and exclude with dataclasses Sep 8, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2022

📝 Docs preview for commit 693c8a4 at: https://6319fbeea7f68600ba4ea21d--fastapi.netlify.app

@tiangolo
Copy link
Owner

tiangolo commented Sep 8, 2022

Awesome, thank you @DCsunset! 🚀 🍰

@tiangolo tiangolo merged commit 3ec498a into tiangolo:master Sep 8, 2022
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.

None yet

4 participants