redux-toolkit icon indicating copy to clipboard operation
redux-toolkit copied to clipboard

Codegen generating nullable while OpenAPI spec doesn't define nullable

Open michel-jump opened this issue 7 months ago • 1 comments

The OpenAPI spec:

"TestEntityDto": {
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "name": {
      "type": "string",
      "nullable": true
    },
    "created": {
      "type": "string",
      "format": "date-time"
    },
    "lastModified": {
      "type": "string",
      "format": "date-time"
    }
  },
  "additionalProperties": false
},

The generated type:

export type TestEntityDto = {
  id?: string;
  name?: string | null;
  created?: string;
  lastModified?: string;
};

Why is the id nullable?

michel-jump avatar Apr 07 '25 09:04 michel-jump

It's not nullable, it's optional, because you didn't mark it as required: https://swagger.io/docs/specification/v3_0/data-models/data-types/#objects

EskiMojo14 avatar Apr 07 '25 09:04 EskiMojo14