openapi-codegen-ts icon indicating copy to clipboard operation
openapi-codegen-ts copied to clipboard

[CHK-1807] feat: allow object properties to be defined with `oneOf`

Open giovanniberti opened this issue 2 years ago • 1 comments

Description

  • added checking for oneOf when defining object properties

Motivation and Context

This PR implements defining object properties with oneOf. Property definition with oneOf is permitted by the OpenAPI spec but currently fails with an error during generation (note that this is a different case from a separate schema defined with oneOf).

Note that this PR:

  • does not add support for discriminator (which has more requirements, for example it cannot be used with inline schemas). Code generation doesn't fail with discriminator but no schema checking is made and no special type information about the discriminator is propagated to the generated code.
  • does not add support for defining object properties with allOf or anyOf (should we add it in this PR or in another one? I don't like very much supporting oneOf for properties but not the others)

How Has This Been Tested?

Manual inspection of generated snapshots used for testing

Screenshots (if appropriate):

Types of changes

  • [ ] Chore (improvement with no change in the behaviour)
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.

giovanniberti avatar Aug 09 '23 13:08 giovanniberti

Jira Pull Request Link

This Pull Request refers to the following Jira issue CHK-1807

github-actions[bot] avatar Aug 09 '23 13:08 github-actions[bot]