swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.92k stars 6.03k forks source link

how to use -Dapis flag #11314

Open adamgreenhall opened 2 years ago

adamgreenhall commented 2 years ago
Description

I'm trying to figure out how to use the -Dapis flag to filter the api paths being generated, but I can't seem to figure it out. And it's not documented with the other examples in https://github.com/swagger-api/swagger-codegen#selective-generation

Swagger-codegen version

3.0.30

Swagger declaration file content or url

https://petstore.swagger.io/v2/swagger.json

Command line used for generation

I've tried a few different things - none of them seem to work:

Using the path tag (but capitalized for some reason, lowercase doesn't work) does generate all code for api path methods with that tag: java -Dapis="Pet" -jar swagger-codegen-cli.jar generate -l go -i https://petstore.swagger.io/v2/swagger.json -o test but I'd like to filter to a subset of these methods, if possible.

Suggest a fix/enhancement

Ideally, we could document how to use the -Dapis flag to filter apis.

reference

flag handling code appears to be here:

https://github.com/swagger-api/swagger-codegen/blob/1c5b1ab00e05f8256b2f2df32b1b784a9b365978/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java#L464

mengjiann commented 2 years ago

I got it to work with the tags from the paths attribute. Please try.

adamgreenhall commented 2 years ago

I got it to work with the tags from the paths attribute. Please try.

@mengjiann can you give an example?