OpenAPITools / OpenAPITools/openapi-generator
[REQ][TYPESCRIPT-AXIOS] Add option to not stringify JSON data in axios-typescript generator
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Problem Statement
The generator always serializes objects to string with JSON.stringify. This is not always wanted, which is why it should configurable. In my case I wanted to write an AxiosTransformer, which transforms JavaScript Date types to the correct format. In order to do this now, I have to JSON.parse the data and then check it.
Here is the line in question:
https://github.com/OpenAPITools/openapi-generator/blob/ce49fe587fe6ab4dcc2275590f49fb0b09777710/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache#L199
Prefered Solution
Add new option to the config, when generating the client:
{
"stringifyRequestData": false
}
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 modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache at the linked JSON.stringify call, then trace how typescript-axios generator options reach that template. Done means the new stringifyRequestData option can disable serialization while preserving the existing default behavior; verify the generated client output for both settings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100