OpenAPITools / OpenAPITools/openapi-generator

[REQ] [typescript-*] add flag to don't convertation some types

Open
#10,088 0 comments 0 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

Hello!
I partially use your wonderful tool to generate types for redux-toolkit-query. More details can be found here:
https://github.com/rtk-incubator/rtk-query-codegen/issues/63#issuecomment-879219548

However, when the API changes, I have to compare the new generated files with the old ones.
For example, since Redux prefers to store serializable data, I need to rewrite the generated date to string types, and then I need to rewrite some functions that convert strings to dates.
From:

interface Car {
  id: string;
  yearOfManufacture: Date;
}
function CarFromJSON(json: any): Car {
  return {
    id: json['id'],
    yearOfManufacture: new Date(json['year_of_manufacture']),
  };
}

To:

interface Car {
  id: string;
  yearOfManufacture: string;
}
function CarFromJSON(json: any): Car {
  return {
    id: json['id'],
    yearOfManufacture: json['year_of_manufacture'],
  };
}

So...
With each new iteration, the number of models grows, and such differences between the generated types and the actual ones remain. This makes Diff very difficult.

What I suggest:
Perhaps there is a way to make the generator behavior customizable? For example for data serializability.

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 by reviewing the TypeScript generator entry points and the linked RTK Query discussion. Define the configuration needed to keep selected generated types serializable and identify how the corresponding conversion functions should change; done means the behavior is configurable without manually rewriting generated models.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.