Description

Repository to reproduce the issue.

Nullable enum are not generated as nullable using NestJS and openapi-generator (latest version - 5.4)

Installation

$ npm install

Generate the OpenApi

# generate the openapi.json file and the angular client
npm run generate:angular-client

(you can also generate only the openapi.json file using npm run generate:openapi-specs)

Bug description (Nest or OpenApi Generator ?)

Based on the dto :

  @ApiProperty({ enum: FooBarEnum, enumName: 'FooBarEnum', nullable: true })
  value!: FooBarEnum | null;

  @ApiProperty({ oneOf: [{ type: 'enum', $ref: 'FooBarEnum', nullable: true }] })
  workaround!: FooBarEnum | null;

The openapi.json generated file contains those properties:

  "value": {
    "nullable": true,
    "$ref": "#/components/schemas/FooBarEnum"
  },
  "workaround": {
    "oneOf": [
      {
        "type": "enum",
        "$ref": "FooBarEnum",
        "nullable": true
      }
    ]
  },

And the angular client models those:

    value: FooBarEnum;
    workaround: FooBarEnum | null;