GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: Apply required overrides from allOf schemas by peter-goldstein · Pull Request #1384 · openapi-generators/openapi-python-client

Conversation

@peter-goldstein

@peter-goldstein peter-goldstein commented Jan 9, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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.

All reactions
peter-goldstein added 3 commits January 9, 2026 07:44
@peter-goldstein
fix: Apply required overrides from allOf schemas
c6e8448
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.
@peter-goldstein
test: Add unit test for allOf required override
be1b6d3
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.
@peter-goldstein
test: Add end-to-end test for allOf required override
77e52ae
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.
@peter-goldstein
peter-goldstein marked this pull request as draft January 9, 2026 13:34
@peter-goldstein
peter-goldstein marked this pull request as ready for review January 9, 2026 13:34
@peter-goldstein
Fix format with ruff
042a00a
dbanty
dbanty approved these changes Jan 10, 2026
View reviewed changes
@dbanty
dbanty added this pull request to the merge queue Jan 10, 2026
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.

@knope-bot knope-bot Bot mentioned this pull request Jan 10, 2026
Release 0.28.1 #1385
Merged
github-merge-queue Bot pushed a commit that referenced this pull request Jan 10, 2026
@knope-bot
Release 0.28.1 (#1385)
454f989
> [!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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@dbanty dbanty dbanty approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

2 participants

@peter-goldstein @dbanty
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.