Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

nullable: true don't produce the correct type #142

Closed
fabien0102 opened this issue Jul 30, 2019 · 1 comment
Closed

nullable: true don't produce the correct type #142

fabien0102 opened this issue Jul 30, 2019 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@fabien0102
Copy link
Collaborator

Describe the bug

On our openAPI generator, nullable: true should produce a | null in the resulted generated type.

Reproduction steps

Schema:

 components:
  schemas:
    PrimitiveStrictValue:
      oneOf:
        - type: string
        - type: boolean
        - type: number

    PrimitiveValue:
      $ref: '#/components/schemas/PrimitiveStrictValue'
      nullable: true

Result:

export type PrimitiveStrictValue = string | boolean | number;

export type PrimitiveValue = PrimitiveStrictValue;

Expected:

export type PrimitiveStrictValue = string | boolean | number;

export type PrimitiveValue = PrimitiveStrictValue | null;

References
https://swagger.io/specification/#schemaNullable

@fabien0102 fabien0102 added the bug Something isn't working label Jul 30, 2019
@fabien0102 fabien0102 self-assigned this Jul 30, 2019
@fabien0102
Copy link
Collaborator Author

OAI/OpenAPI-Specification#1368

This is actually how it's suppose to be (or at least how every other tool treat this problem, so let's be aligned)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant