Skip to content

fix: $ref siblings like default affecting all ref instances - #1758

Open
infastin wants to merge 2 commits into
ogen-go:mainfrom
infastin:fix/ref-overrides
Open

infastin wants to merge 2 commits into
ogen-go:mainfrom
infastin:fix/ref-overrides

Conversation

@infastin

@infastin infastin commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

When a schema had a $ref along with sibling keywords (default, enum, extensions, discriminator), the parser returned the schema directly from refcache and mutated it, so the sibling values leaked into every usage of the referenced schema.

  • parse1 makes a shallow copy of a cached schema (lazily, once) before applying any $ref siblings.
  • Moved x- extension parsing into a separate parseExtension method.
  • Added regression test.

Fixes #1662, #1321.

When a schema had a $ref along with sibling keywords (default, enum,
extensions, discriminator), the parser returned the schema directly
from refcache and mutated it, so the sibling values leaked into
every usage of the referenced schema.

- parse1 makes a shallow copy of a cached schema (lazily, once)
  before applying any $ref siblings.
- Move x- extension parsing into a separate parseExtension method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

allOf: x-oapi-codegen-extra-tags leak to all properties that $ref an entity

1 participant