Skip to content

Fix: Model generation using oneOf, allOf & anyOf#1424

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

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

Conversation

@egormanga
Copy link
Copy Markdown

According to the JSON Schema spec, when a type definition has oneOf, allOf or anyOf 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.

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