Skip to content

docs: document schema-merging-behavior v3, and make it an option - #2581

Merged
mromaszewicz merged 1 commit into
oapi-codegen:mainfrom
mromaszewicz:aggregates/v3-docs
Sep 26, 2026
Merged

mromaszewicz merged 1 commit into
oapi-codegen:mainfrom
mromaszewicz:aggregates/v3-docs

Conversation

@mromaszewicz

Copy link
Copy Markdown
Member

Step 6, the last of the schema-merging-behavior: v3 work (#2564 to #2580). v3 has been accepted but undocumented while it was built. This PR makes it an option like the others, and documents it. v3 ships as an option in v2.9.0, and becomes the default once it has been tested for a while, likely in v2.10.0. Generated code doesn't change, except for the example below.

Docs

  • New docs/schema-merging.md:
    • The three versions:
      • v1 embeds an allOf's member types, and is very limited;
      • v2 is the default;
      • v3 is an option for now.
    • How v1's embedding differs from v2 and v3's composition.
    • v2 and v3 side by side, with the code each generates for every difference:
      • allOf: its merge rules, conflicts, enums (and x-oapi-codegen-enum-merge), a $ref that's only annotated, external and x-go-type members;
      • unions: constraint-only lists, children of a parent that lists them, an allOf of several unions, inline discriminated variants, and closed variants (with lenient-union-accessors).
    • Where v3 reads the spec generously, with the spelling validators also accept.
    • What to check when moving from v2 to v3.
  • README:
    • The anyOf/allOf/oneOf FAQ says there are three ways and links the new page.
    • Its IdentityWithDuplicateField example documented v2's last-wins merge, which v3 rejects. It now refines the property instead, and generates the same code under v2 and v3. examples/anyof-allof-oneof, which it mirrors, changes the same way.
    • The extensions table gets x-oapi-codegen-enum-merge.
  • docs/extensions.md: documents x-oapi-codegen-enum-merge.
  • docs/configuration.md: lists v3 and lenient-union-accessors.

Code

  • SchemaMergingV3 is exported, like SchemaMergingV1 and SchemaMergingV2.
  • v3 is in:
    • the SchemaMergingBehavior doc comment;
    • the unknown-value error, which now lists all three;
    • configuration-schema.json's enum, so editors no longer flag v3.

Every snippet and error message in the new page was generated with this branch's generator.

Checks

make generate changes only examples/anyof-allof-oneof, and make test and make lint pass.

🤖 Generated with Claude Code

v3 has been accepted but undocumented while it was built (oapi-codegen#2564 to
oapi-codegen#2580). This makes it an option like the others, and documents it:

- docs/schema-merging.md explains the three versions: v1 embeds an
  allOf's member types and is very limited, v2 is the default, and v3
  is an option that becomes the default after at least one release as
  one. It shows how v1's embedding differs from v2 and v3's
  composition, compares v2 and v3 side by side with the code each
  generates, lists where v3 reads the spec generously with the spelling
  validators also accept, and says what to check when moving to v3.
- The README's anyOf/allOf/oneOf FAQ says there are three ways and
  links the new page. Its IdentityWithDuplicateField example, which
  documented v2's last-wins merge that v3 rejects, now refines the
  property instead, and generates the same code under v2 and v3; so does
  examples/anyof-allof-oneof, which it mirrors.
- SchemaMergingV3 is exported, and v3 is in the configuration schema's
  enum, the SchemaMergingBehavior doc comment, the unknown-value error
  and docs/configuration.md, which also lists lenient-union-accessors.
- docs/extensions.md and the README's table document
  x-oapi-codegen-enum-merge.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@mromaszewicz
mromaszewicz requested a review from a team as a code owner September 26, 2026 04:07
@greptile-apps

greptile-apps Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds v3 schema-merging behavior as a documented configuration option.

The PR appears safe to merge; no actionable issue was identified.

Summary

The PR exposes v3 as a documented schema-merging option while retaining v2 as the default. It adds migration guidance and updates an example so its merged property generates the same type under v2 and v3.

Reviews (1) · Last reviewed commit: "docs: document schema-merging-behavior v..."

@mromaszewicz
mromaszewicz merged commit cc4438d into oapi-codegen:main Sep 26, 2026
16 checks passed
@mromaszewicz
mromaszewicz deleted the aggregates/v3-docs branch September 26, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant