swagger-typescript-api icon indicating copy to clipboard operation
swagger-typescript-api copied to clipboard

Name flag is not respected when --modular is also provided

Open kevinm416 opened this issue 2 years ago • 4 comments

When I run:

swagger-typescript-api --extract-enums --modular -p ./app/api/openapi.json -o ./app/api/sdk -n generated.server.ts

These files are generated

app/api/sdk/data-contracts.ts
app/api/sdk/http-client.ts
app/api/sdk/Api.ts

It looks like the -n flag is discarded when used with the --modular flag. I couldn't figure out any way to change the output file names when using the --modular flag from the readme.

I would expect app/api/sdk/Api.ts to be named app/api/sdk/generated.server.ts based on the -n flag.

kevinm416 avatar Feb 25 '23 01:02 kevinm416

This issue also affects the --api-class-name argument.

sflanker avatar Mar 28 '23 02:03 sflanker

That's strange that it generated Api.ts when you used the --modular flag. Since it should have generated a separate file for each resource; that's what it does for me.

For example, when I use the Swagger pet store example

npx swagger-typescript-api -p https://petstore3.swagger.io/api/v3/openapi.json -o ./api --modular

It generates

/api/data-contracts.ts
/api/http-client.ts
/api/Pet.ts
/api/Store.ts
/api/User.ts

It does this with or without the -n index.ts flag.

Soviut avatar Jun 30 '23 06:06 Soviut

I'm facing the same problem, but using the API code. Even after I defined the name property the generated file is "Api.ts"

candidodmv avatar Aug 24 '23 14:08 candidodmv