Skip to content

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 SergioSim force-pushed the fix-nested-json-strategy branch from 5ce6912 to f18f623 Compare April 24, 2022 14:45
@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

@github-actions github-actions bot added awaiting author revision awaiting changes from the PR author and removed ready for review labels Jul 19, 2022
@github-actions github-actions bot assigned SergioSim and unassigned samuelcolvin and PrettyWood Jul 19, 2022
@SergioSim SergioSim force-pushed the fix-nested-json-strategy branch from 571e0bb to 31ab8be Compare July 20, 2022 06:53
@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

@github-actions github-actions bot added ready for review and removed awaiting author revision awaiting changes from the PR author labels Jul 20, 2022
@hramezani
Copy link
Member

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

Please update

@github-actions github-actions bot added awaiting author revision awaiting changes from the PR author and removed ready for review labels Jul 20, 2022
When generating a pydantic model having nested Json fields with
hypothesis, a JSON serialization exception was raised.
@SergioSim SergioSim force-pushed the fix-nested-json-strategy branch from 6a5dd1e to 1ec0a47 Compare July 20, 2022 08:31
@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

@github-actions github-actions bot added ready for review and removed awaiting author revision awaiting changes from the PR author labels Jul 20, 2022
@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