Skip to content

Fix: Model generation using oneOf, anyOf & type lists#1424

Open
egormanga wants to merge 1 commit intoopenapi-generators:mainfrom
egormanga:fix/type-variants-merge
Open

Fix: Model generation using oneOf, anyOf & type lists#1424
egormanga wants to merge 1 commit intoopenapi-generators:mainfrom
egormanga:fix/type-variants-merge

Conversation

@egormanga
Copy link
Copy Markdown

@egormanga egormanga commented Apr 13, 2026

According to the JSON Schema spec, when a type definition has oneOf, anyOf or type variation, the variant definition might contain only specific fields, rather than a complete type or reference:

SomeType:
  type: object
  properties:
    x: {type: integer}
    y: {type: integer}
    z: {type: integer}
  required: [x]
  oneOf:
    - required: [y]
    - required: [z]

Currently, in such case the entire type fails to generate and gets treated as Any, resulting in lacking validation.

This implements the proper merging behavior, allowing to fully generate such types with their variants.

Additionally, replaces a relevant error-prone mutating operation, stumbled upon during debugging of this problem, with a non-mutating one due to unnecessity of the former.

@egormanga egormanga force-pushed the fix/type-variants-merge branch from 2276c99 to 8fc093d Compare April 16, 2026 14:01
@egormanga egormanga changed the title Fix: Model generation using oneOf, allOf & anyOf Fix: Model generation using oneOf, anyOf & type lists Apr 16, 2026
@egormanga egormanga force-pushed the fix/type-variants-merge branch from 8fc093d to 2110e3d Compare April 17, 2026 18:44
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.

1 participant