Skip to content

required fields that are nullable generate as NonNullable in typescript #1639

Closed as not planned
@ohnoah

Description

@ohnoah

Description

"type": "array",
              "items": {
                  "type": "object",
                  "properties": {
                      "first_name": {
                          "type": "string"
                      },
                      "profile_picture_url": {
                          "type": "string",
                          "nullable": True,
                      },
                  },
                  "required": [
                      "unique_id",
                      "first_name",
                      "last_name",
                      "profile_picture_url",
                  ],
              }

In this example OpenAPI spec, I get a generated type where profile_picture_url is of type string, not string | undefined or string | null.

Reproducible example or configuration

"type": "array",
              "items": {
                  "type": "object",
                  "properties": {
                      "first_name": {
                          "type": "string"
                      },
                      "profile_picture_url": {
                          "type": "string",
                          "nullable": True,
                      },
                  },
                  "required": [
                      "unique_id",
                      "first_name",
                      "last_name",
                      "profile_picture_url",
                  ],
              }
                `"npx",
                "@hey-api/openapi-ts",
                "-i",
                "generated/openapi.json",
                "-o",
                output_dir,
                "-c",
                "@hey-api/client-fetch",`

OpenAPI specification (optional)

"type": "array",
              "items": {
                  "type": "object",
                  "properties": {
                      "first_name": {
                          "type": "string"
                      },
                      "profile_picture_url": {
                          "type": "string",
                          "nullable": True,
                      },
                  },
                  "required": [
                      "unique_id",
                      "first_name",
                      "last_name",
                      "profile_picture_url",
                  ],
              }

System information (optional)

Latest versions of everything as of Jan 29

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions