Repository navigation
fix(python): validate string enum values excluded by not - #25070
Merged
wing328 merged 3 commits intoOct 5, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Contributor
Author
|
@fa0311 @krjakbrjak would you mind taking a look when you have a chance? This is a small Python client bug fix with regression coverage and green CI. This issue currently blocks our work on a new Dropbox SDK generated with OpenAPI Generator, so getting it into the next release would be very helpful. Thanks! |
Member
|
python tests (with new schemas covering the change) passed via #25123 |
3 tasks
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.
Description
Fix Python client validation for string enum values excluded by an
OpenAPI
notschema.For a property such as:
the Python generator previously emitted a plain
StrictStrwithoutenforcing the
notconstraint. This could cause multipleoneOfschemas to match the same payload.
This change:
composedSchemas.not;field_validatorwhen this validation is required;Generated validation now includes:
This allows
oneOfvariants usingnot: enumto remain mutuallyexclusive.
Tests
Added
testOneOfNotEnumValidationtoPythonClientCodegenTest.The generated client was also verified at runtime:
Other.from_json('{"kind":"known"}')is rejected with a validationerror.
Other.from_json('{"kind":"other"}')succeeds.TaggedUnion.from_json('{"kind":"known"}')resolves toKnown.TaggedUnion.from_json('{"kind":"other"}')resolves toOther.Fixes #25069
Summary by cubic
Fixes Python client validation for string enum values excluded by an OpenAPI
notschema. Previously, the generator emitted a plainStrictStrwithout enforcing thenotconstraint, so multipleoneOfschemas could match the same payload. The generator now reads excluded enum values fromcomposedSchemas.not, preserves them as a vendor extension, and generates a Pydanticfield_validatorthat rejects those values, emitted once per property. This keepsoneOfvariants usingnot: enummutually exclusive. Also adds a regression test and an OpenAPI 3.1 fixture.Written for commit 1f1b1a7. Summary will update on new commits.