Skip to content

Invalid union generated for anyOf with nullable: true (string | | null) #2339

@ruangustavo

Description

@ruangustavo

It's producing invalid union types with an empty branch (| |) that falls back to any

Example input (Swagger):

dataVencimento:
  anyOf:
    - type: string
      format: date-time
    - nullable: true
      enum:
        - null

Generated output

export type ListFreguesias200ItemDataVencimento = string |  | null;

Expected output:

export type ListFreguesias200ItemDataVencimento = string | null;

Note:
The same issue happens with non–date-time strings:

terminacao:
  anyOf:
    - type: string
    - nullable: true
      enum:
        - null

Generates:

export type ListFreguesias200ItemTerminacao = string |  | null;

Instead of:

export type ListFreguesias200ItemTerminacao = string | null;

I'm using the latest version ^7.11.2

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