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

Fix Json strategy serialization failure #4005

Merged
merged 1 commit into from Aug 8, 2022

Conversation

SergioSim
Copy link
Contributor

@SergioSim SergioSim commented Apr 24, 2022

When generating pydantic models having nested Json fields with
hypothesis, a JSON serialization exception was raised.

Change Summary

Changed the resolve_json function in pydantic/_hypothesis_plugin.py to use the pydantic json serializer if the type passed to the Json field is a subclass of pydantic.BaseModel.

Related issue number

fix #4004

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@SergioSim
Copy link
Contributor Author

please review

@hramezani
Copy link
Member

Thanks @SergioSim for the patch 👍
Please add a change file based on the checklist format and describe your fix there.

Please update

@SergioSim
Copy link
Contributor Author

Thanks @SergioSim for the patch +1 Please add a change file based on the checklist format and describe your fix there.

Please update

Thanks for the review @hramezani 👍

Added the change file.

please review

@hramezani
Copy link
Member

Thanks @SergioSim for updating. Just a small improvement in the change file.

Please update

When generating a pydantic model having nested Json fields with
hypothesis, a JSON serialization exception was raised.
@SergioSim
Copy link
Contributor Author

Thanks @SergioSim for updating. Just a small improvement in the change file.

Please update

Thanks for your feedback @hramezani 👍

Updated the change file.

Please review

@samuelcolvin samuelcolvin merged commit c356011 into pydantic:master Aug 8, 2022
@samuelcolvin
Copy link
Member

thanks so much.

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

Successfully merging this pull request may close these issues.

Json strategy fails serializing nested pydantic Models
4 participants