OpenAPITools / OpenAPITools/openapi-generator

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

Open
#16,020 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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];

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file or test is named. Generate a typescript-fetch client from the provided YAML parameter and inspect the generated query serialization shown in the report. Done means a parameter with format: date is serialized as a date-only value such as "2017-07-21", rather than date-time output.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.