Skip to content

[BUG] [typescript-fetch] Parameters with format: date are treated like date-time instead #16020

Open
@michasng

Description

@michasng
Description

If I specify a request with a date parameter, with type: string and format: date, then according to relevant documentation, this should be formatted as "2017-07-21", but it is instead formatted as "2017-07-21T17:32:28Z".

openapi-generator version

org.openapi.generator version 6.6.0
using the typescript-fetch generator.

OpenAPI declaration file content or url
parameters:
  name: startDate
  in: query
  schema:
    type: string
    format: date
Generation Details
Steps to reproduce

Simply generate any client with above snippet and look at the output or call the client with any Date object.

Suggest a fix

The generated code does:

queryParameters["startDate"] = (requestParameters.startDate as any).toISOString();

where it should be doing:

queryParameters["startDate"] = requestParameters.startDate.toISOString().split('T')[0];

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