GeezerVison is showing github.com — fix: Apply required overrides from allOf schemas by peter-goldstein · Pull Request #1384 · openapi-generators/openapi-python-client
Conversation
Summary
Fixes an issue where required field overrides in allOf schemas were being ignored when the base schema was referenced. Properties inherited from a base schema can now be correctly marked as required in derived schemas.
Problem
When using allOf with a reference to a base schema and then marking fields as required in a second schema, the generator was ignoring the required override. For example:
components:
schemas:
FooBase:
type: object
properties:
bar:
type: string
baz:
type: string
FooCreate:
allOf:
- $ref: '#/components/schemas/FooBase'
- type: object
required:
- bar
New behavior
A field will be required if it was marked required in the base schema or the derived schema. There is no way to remove a required restriction in a derived schema. This is because for a message to be valid under an allOf, it must be valid under all of the parent schemas.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
When using allOf with a reference to a base schema and then marking
fields as required in a second schema, those fields are now correctly
generated as required in the derived class.
Properties inherited from referenced models are now updated to reflect
required field overrides from the containing schema after all allOf
schemas and their required fields are collected.
Add test_allof_required_override to verify that properties inherited
from a base schema via allOf can be correctly marked as required in
the derived schema's required list.
Add AllOfRequiredBase and AllOfRequiredDerived schemas to baseline
specs to verify the generated code correctly handles required field
overrides in allOf schemas. Update golden records accordingly.
Merged
via the queue into
openapi-generators:main
with commit
e428569
Jan 10, 2026
22 checks passed
Uh oh!
There was an error while loading. Please reload this page.
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Jan 10, 2026
> [!IMPORTANT]
> Merging this pull request will create this release
## Fixes
- Apply required overrides from allOf schemas (#1384)
- Sort lazy imports to increase stability of generated code (#1378)
Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>
Reviewers
dbanty
dbanty approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.