OpenAPITools / OpenAPITools/openapi-generator

[BUG] Cannot compile generated code with `typescript-axios` with parameter named `configuration`

Open
#7,880 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • [ x] Have you provided a full/minimal spec to reproduce the issue?
  • [ x] Have you validated the input using an OpenAPI validator (example)?
  • [ x] Have you tested with the latest master to confirm the issue still exists?
  • [ x] Have you searched for related issues/PRs?
  • [ x] What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The code will not compile when I generate code with the typescript-axios generator and my OpenApi file contains a parameter named configuration. The parameter name will conflict with the configuration variable in the API classes.

openapi-generator version

4.3.1

OpenAPI declaration file content or url

Part of the OpenAPI file which contains an endpoint with a parameter named configuration.

  /sites/{siteid}/{code}:
    post:
      parameters:
      - in: path
        name: siteid
        required: true
        type: string
      - in: path
        name: code
        required: true
        type: string
      - in: body
        name: configuration
        required: true
        schema:
          $ref: '#/definitions/ConfigurationData'
Generation Details

java -jar openapi-generator-clijar generate --generator-name typescript-axios --input-spec openapi.yaml

Steps to reproduce

Generate code with the command above will work without any errors, but running tcs on the generated code will fail.

Related issues/PRs

A similar issue for the typescrip-fetch generator:
https://github.com/OpenAPITools/openapi-generator/issues/2564

Suggest a fix

Add configuration to list of reserved words in AbstractTypeScriptClientCodegen.
Alternatively, add it to the list of reserved words in the TypeScriptAxiosClientCodegen.

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 in AbstractTypeScriptClientCodegen and TypeScriptAxiosClientCodegen, where reserved words for generated TypeScript are defined. Generate the supplied OpenAPI example with the typescript-axios command, then run tsc on the generated code. Done means a body parameter named configuration no longer conflicts with the API client's configuration variable.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.