Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for optional objects in openapi 3.1.0 #338

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

nils-degroot
Copy link
Contributor

@nils-degroot nils-degroot commented Dec 10, 2024

Currently mapping from openapi 3.1.0 nullable types only works with the types array which does not support object. This pr provides mapping for oneOf (object | null) to the legacy style mapping. See the following input openapi spec:

openapi: 3.1.0
components:
  schemas:
    NullableObject:
      type: object
      properties:
        field:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TheObject'
    TheObject:
      properties:
        name:
          type: string

It would be updated to this openapi spec after this pr:

openapi: 3.1.0
components:
  schemas:
    NullableObject:
      type: object
      properties:
        field:
          allOf:
            - $ref: '#/components/schemas/TheObject'
          nullable: true
    TheObject:
      properties:
        name:
          type: string

@cjbooms
Copy link
Owner

cjbooms commented Dec 10, 2024

Nice one. Thanks for the contribution

@cjbooms cjbooms merged commit 7f94d47 into cjbooms:master Dec 10, 2024
1 check passed
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.

2 participants