Repository navigation
docs: document schema-merging-behavior v3, and make it an option - #2581
Merged
Merged
Conversation
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]>
Contributor
|
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.
Step 6, the last of the
schema-merging-behavior: v3work (#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
docs/schema-merging.md:x-oapi-codegen-enum-merge), a$refthat's only annotated, external andx-go-typemembers;lenient-union-accessors).IdentityWithDuplicateFieldexample 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.x-oapi-codegen-enum-merge.docs/extensions.md: documentsx-oapi-codegen-enum-merge.docs/configuration.md: lists v3 andlenient-union-accessors.Code
SchemaMergingV3is exported, likeSchemaMergingV1andSchemaMergingV2.SchemaMergingBehaviordoc comment;configuration-schema.json's enum, so editors no longer flagv3.Every snippet and error message in the new page was generated with this branch's generator.
Checks
make generatechanges onlyexamples/anyof-allof-oneof, andmake testandmake lintpass.🤖 Generated with Claude Code