OpenAPITools / OpenAPITools/openapi-generator

[REQ] Alternative means for deriving api parameter names

Open
#12,482 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

Is your feature request related to a problem? Please describe.

We have an endpoint that takes in a json object in the body which can be one of about 20 different types. This is expressed with anyOf in our spec. We are using the typescript-axios generator. The generated code is functional, but the functions in ApiAxiosParamCreator have parameters with crazy long names (500+ characters - all of the possible types in the union concatented).

Describe the solution you'd like

I'd like to implement some sort of alternative means of generating these parameter names (assuming this feature doesn't exist). Specifically I'd to be able to set a flag to base the parameter name on whatever substring is common across all types in the union. In our case the endpoint deals with specific operations, e.g. AddOperation, SubtractOperation (obviously not this trivial). In this case the generated parameter name might be "operation"

Describe alternatives you've considered

We've tried alternative ways of specifying the input parameter type in the spec (e.g. using an abstract class + discriminator) but we don't want to change the spec for the sake of altering the generated code.

Additional context

I'm not sure if this should be considered a feature or a bug. Having parameters names in excess of 500 characters seems like it could be considered a bug.

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 the typescript-axios generator and reproduce the issue using an anyOf request body containing many types. Inspect how ApiAxiosParamCreator derives parameter names; done should include an alternative naming mechanism that avoids 500+ character names while preserving functional generated code.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.