Skip to content

[BUG][typescript-fetch] Nullable date types are not marked as | null + coverters only check undefined #11307

@WilliamABradley

Description

@WilliamABradley

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When calling an API with a null date, you can't because the typescript type is wrong, and if you fudge it, it will throw an error because .toISOString does not exist on null.

openapi-generator version

5.3.0

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: Example
  version: v1
paths: {}
components:
  schemas:
    Date:
      type: string
      format: date-time
      nullable: true
Generation Details
{
  "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "5.3.0",
    "generators": {
      "user-api": {
        "generatorName": "typescript-fetch",
        "output": "src/libs/user-api",
        "inputSpec": "https://.../users/v1/docs/spec/public/users/openapi.yml",
        "additionalProperties": {
          "modelPropertyNaming": "original",
          "enumNameSuffix": ""
        }
      }
    }
  }
}
Steps to reproduce

Run openapi-generator-cli generate

Related issues/PRs
Suggest a fix

Make types:

col?: Date | null;

Make coverter:

'col': value.col === undefined ? undefined : (value.date_of_birth.toISOString()),

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions