OpenAPITools / OpenAPITools/openapi-generator
[BUG] [typescript-axios] parameter with date format has incorrect types
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
If a date format is specified for a parameter, the generated code for axios will include the following:
if (fromDate !== undefined) {
localVarQueryParameter['fromDate'] =
(fromDate as any) instanceof Date
? (fromDate as any).toISOString().substr(0, 10)
: fromDate;
}
However, the type for that argument in the generated method is fromDate?: string, which prevent us from actually passing a Date instance.
Either we remove that code, or change the type definition to be fromDate?: string | Date
openapi-generator version
4.3.1
OpenAPI declaration file content or url
parameters:
- in: query
name: fromDate
schema:
type: string
format: date
Command line used for generation
openapi-generator \
generate \
-g typescript-axios \
-i "../external-api/$name.yaml" \
-o "generated-src/$name"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the typescript-axios generator and reproduce the provided OpenAPI declaration and generation command. Inspect the generated method signature and query-parameter handling for a date-formatted parameter. Done means the generated TypeScript type and runtime date handling agree, with the generated output matching the intended behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100