OpenAPITools / OpenAPITools/openapi-generator
typescript client does not respect optional parameters by default
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
According to the OpenAPI Spec, request parameters should be treated optional by default.
The client-generator for typescript treats them as mandatory by default, thus converting unspecified parameters to string undefined which may break the API:
My suggestion is:
- check if the parameter is
requiredand if not: - check if the value is undefined or not before calling
setHeaderParam.
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 linked modules/openapi-generator/src/main/resources/typescript/api/api.mustache template around line 75 and inspect how parameters are handled in generated TypeScript clients. The change is complete when optional, unspecified parameters are not converted to the string "undefined" before the request is sent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100