fix(core): preserve primitive validation in JSON Schema unions - #8267
Open
黄耀鑫(Huang Yaoxin) (YaoxinHuang) wants to merge 2 commits into
Open
黄耀鑫(Huang Yaoxin) (YaoxinHuang) wants to merge 2 commits into
黄耀鑫(Huang Yaoxin) (YaoxinHuang) wants to merge 2 commits into
Conversation
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.
Why are these changes needed?
schema_to_pydantic_model()drops numeric bounds, string constraints, and formats from primitiveanyOf/oneOfbranches. For example, an integer-or-null field withminimum: 0accepts-1after conversion.Use the existing field-type conversion for string, integer, and number union branches, preserving their validation. Array, reference, enum, and object handling stays the same. Add regression cases for numeric bounds, string lengths/patterns, and email format, including valid boundary values and null.
Related issue number
No existing issue found for primitive union validation. This is separate from #6925, which handled array branches.
Validation
pytest packages/autogen-core/tests/test_json_to_pydantic.py -q: 91 passed.Checks
This change and its regression tests were prepared with Codex.