OpenAPITools / OpenAPITools/openapi-generator

[REQ][TYPESCRIPT-AXIOS] Add option to not stringify JSON data in axios-typescript generator

Open
#5,717 6 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.