swagger-codegen-generators icon indicating copy to clipboard operation
swagger-codegen-generators copied to clipboard

[typescript-axios] Generated interfaces contain forbidden modifier async

Open leonidasv opened this issue 2 years ago • 0 comments

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

leonidasv avatar Nov 25 '22 00:11 leonidasv