Rework how JSON schema refs get built/"simplified"#6402
Merged
Conversation
adriangb
reviewed
Jul 4, 2023
Comment on lines
+175
to
+177
| warnings.warn( | ||
| 'Failed to simplify the JSON schema definitions, this may be a bug in Pydantic', PydanticJsonSchemaWarning | ||
| ) |
Member
There was a problem hiding this comment.
I feel like we should just error here. I'd rather have someone report the error so we can fix it with a reproducible example than just warn.
Contributor
Author
There was a problem hiding this comment.
Converted to an error
Deploying with
|
| Latest commit: |
1763af4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2f80a182.pydantic-docs2.pages.dev |
| Branch Preview URL: | https://dmontagu-6369.pydantic-docs2.pages.dev |
adriangb
approved these changes
Jul 4, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This closes #6369, and also addresses various other issues:
id(model)to ensure the names were unique, but this would result in different schemas on every run. In this PR I have fixed this so that when there are qualname conflicts, we add__1to the first encounter with that qualname,__2to the second, etc., instead of using theid.However, this PR currently involves some changes to the "ostensibly-public" APIs of
GenerateJsonSchema.@samuelcolvin: @adriangb and I discussed and I think we should make some of the "implementation detail" methods from
GenerateJsonSchemaprivate (which I at least partially do in this PR..), and publish something describing in more detail what we intend to treat as public and what we don't from the semver perspective.In particular, after discovering the issues with the current approach from investigating #6369, I really think we should change the implementation a bit, which is done in the PR I'm about to open, but technically it involves replacing some public methods of
GenerateJsonSchema. I think given how advanced this use case is we should probably make this change now.Happy to discuss more before merging anything, and happy to put in more effort to rework this to not have any theoretically-breaking changes, but I think there's an argument to be made that we never intended to make these methods public and that we are now renaming them to make them private.