swagger-api / swagger-api/swagger-codegen-generators

[typescript-axios] Generated interfaces contain forbidden modifier async

Open
#1,085 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

Description

Generated interfaces from typescript-axios when ran with the additional property withInterfaces=true contains the keyword async for methods returning Promises. However, the async modifier is not allowed in interfaces.

Compiling the resulting interfaces with tsc results in:

error TS1070: 'async' modifier cannot appear on a type member.
Swagger-codegen version
3.0.36
Swagger declaration file content or url

https://github.com/swagger-api/swagger-codegen/blob/v3.0.36/modules/swagger-codegen/src/test/resources/3_0_0/petstore-mixed.yaml

Command line used for generation
swagger-codegen generate -i modules/swagger-codegen/src/test/resources/3_0_0/petstore-mixed.yaml -l typescript-axios -o samples/client/petstore/typescript-axios/petstore-mixed --flatten-inline-schema=true --additional-properties=withInterfaces=true
Steps to reproduce
  1. Install npm >=8.0, tsc >=4.8 and swagger-codegen =3.0.36
  2. Clone this repository and checkout tag v3.0.36
  3. Run the following command
  4. cd into samples/client/petstore/typescript-axios/petstore-mixed
  5. Run npm install
  6. Run tsc

Example output:
image

Inspecting given lines, for example, apis/user-api.ts:670:5 shows that in fact it's a member of an interface:
image

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 generation command and the 3_0_0/petstore-mixed.yaml fixture, then inspect the generated samples/client/petstore/typescript-axios/petstore-mixed/apis/user-api.ts file. Run npm install followed by tsc and verify that generated interface members compile without the reported TS1070 error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.