Skip to content

[BUG] typescript-axios can't pass date-time as strings #5683

@zanonnicola

Description

@zanonnicola
Description

I have this schema definition:

"payPeriodStart": {
      example: "2020-02-12T06:00:00Z",
      required: true,
      description: "Start of the pay period",
      schema: {
        type: "string",
        format: "date-time",
      },
    }
}

When the type have a date-time format, the interface generated says that it requires a Date object.
Should be a string.

/**
         * 
         * @param {string} a
         * @param {Date} payPeriodStart Start of the pay period
         * @param {Date} payPeriodEnd End of the pay period
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        reportsControllerGetRepaymentInstructionReport(a: string, payPeriodStart: Date, payPeriodEnd: Date, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise<string> {

I tried to use add --type-mappings DateTime=string to the CLI but then it will convert both Date and date-time to string, regardless.

This happens in typescript-axios generator

openapi-generator version

4.2.3

OpenAPI declaration file content or url
{
"parameters": [
{
"name": "payPeriodStart",
"in": "query",
"schema": {
"type": "string",
"format": "date-time"
},
"example": "2020-02-12T06:00:00Z",
"required": true,
"description": "Start of the pay period"
}
]
}
Command line used for generation
java  -Dcolor -jar openapi-generator-4.2.3.jar generate  -i http://localhost:8080/openapi.json -g typescript-axios --remove-operation-id-prefix -t ../src/api_client/typescript-axios -c ../src/api_client/config.json -o ../src/api_client
Steps to reproduce
Related issues/PRs

Not sure if this is the intended behaviour but maybe the mapping in the CLI should recognise the difference between date and date-time.

Thanks!

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