cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
403 stars 134 forks source link

Nullable array elements are not generated nullable in models #255

Closed flpa closed 1 year ago

flpa commented 1 year ago

Hey, I'm currently working on an API with the following type:

{
  "TfcHeaderFilterDTO": {
    "required": [
      "values"
    ],
    "type": "object",
    "properties": {
      "typeExclude": {
        "type": "boolean"
      },
      "values": {
        "type": "array",
        "items": {
          "type": "string",
          "nullable": true
        }
      }
    }
  }
}

The "values" property is supposed to hold an array of nullable Strings. According to this topic, the items should be explicitly marked as nullable in such cases (like in my snippet above): https://community.smartbear.com/t5/Swagger-Open-Source-Tools/Array-null-values/td-p/192153

However, when generating models for the API, the type is generated as follows:

export interface TfcHeaderFilterDto {
  typeExclude?: boolean;
  values: Array<string>;
}

What I am trying to achieve is something like this, though:

export interface TfcHeaderFilterDto {
  typeExclude?: boolean;
  values: Array<string | null>;
}

Am I missing something? Or is there a way to make ng-openapi-gen generate the type like that?

luisfpg commented 1 year ago

This seems like a bug. Unfortunately I'm having little to no time for this project. But I'll try to include it in the next release.