You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: make enum union/intersection generation more configurable #1633
This is now configurable on main, with the new schema-merging-behavior: v3 (#2572). A value must match every member of an allOf, so v3 keeps only the enum values the members have in common, and reports an error when they have none. The x-oapi-codegen-enum-merge: union extension asks for all the members' values instead, for a composition that adds values to an enum:
This generates active, inactive and archived. The extension goes on the schema with the allOf, or on a member's property that refines a property; docs/extensions.md has the details. v2 is unchanged: it always takes all the values, and ignores the extension.
To try it, set this in your configuration:
compatibility:
schema-merging-behavior: v3
There's no release with v3 yet, so you'll need the latest main, for example go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@main --config=config.yaml spec.yaml. docs/schema-merging.md describes how v3 differs from v2. v3 is an option for now, and we plan to make it the default once it has been tested for a while, so we're eager to hear your feedback: whether it works with your specs, and anything it generates that you didn't expect.
Activity
feat(v3): merge allOf keywords by their meaning, and name conflicts
mromaszewicz commentedon Sep 26, 2026
This is now configurable on
main, with the newschema-merging-behavior: v3(#2572). A value must match every member of anallOf, so v3 keeps only the enum values the members have in common, and reports an error when they have none. Thex-oapi-codegen-enum-merge: unionextension asks for all the members' values instead, for a composition that adds values to an enum:This generates
active,inactiveandarchived. The extension goes on the schema with theallOf, or on a member's property that refines a property; docs/extensions.md has the details. v2 is unchanged: it always takes all the values, and ignores the extension.To try it, set this in your configuration:
There's no release with v3 yet, so you'll need the latest
main, for examplego run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@main --config=config.yaml spec.yaml. docs/schema-merging.md describes how v3 differs from v2. v3 is an option for now, and we plan to make it the default once it has been tested for a while, so we're eager to hear your feedback: whether it works with your specs, and anything it generates that you didn't expect.This message was generated by AI.
feat(v3): merge allOf members by what allOf means (oapi-codegen#2572)