Skip to content

Nullable object fields don't get generated correctly #2058

@valzam

Description

@valzam

Describe the bug
A TS type like this

interface A {
 foo: string;
}

interface B {
 bar: A | null
}

results in the following OpenAPI spec:

components:
 schema:
    B:
      type: object
      properties:
        bar:
          $ref: '#/components/schemas/A'
          nullable: true

This doesn't work as expected in OpenAPI 3.0 (the nullable is simply ignored)
OAI/OpenAPI-Specification#1368

Expected behavior
The field definition needs to use allOf

bar:
  nullable: true
  allOf:
  - $ref: '#/components/schemas/A'

https://stackoverflow.com/questions/40920441/how-to-specify-a-property-can-be-null-or-a-reference-with-swagger

Desktop (please complete the following information):
Spot version 1.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions