Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate only models using Swagger-api / swagger-codegen

Generating the typescript-angular files from the downloaded jar swagger-codegen-cli-3.0.34.jar

Command

java -jar tools/swagger-codegen-cli-3.0.34.jar generate \
  -i http://localhost:8080/swagger/fete-bird-api-gateway-0.0.yml \
  -l typescript-angular \
  -o libs/service/src/lib/swagger-specification \
  -Dmodels=true \
  -DmodelDocs=false -DmodelTests=false \
  -c tools/angular-swagger-option.json

The files are generated successfully, however, I am trying to generate only the models not the API, but the above command-generated API as well

enter image description here

Followed the instructions from https://github.com/swagger-api/swagger-codegen

# generate only models
java -Dmodels {opts}

# generate only apis
java -Dapis {opts}

# generate only supporting files
java -DsupportingFiles

# generate models and supporting files
java -Dmodels -DsupportingFiles

Not sure what should I pass {opts} so, that it generates only Models not api

like image 803
San Jaisy Avatar asked Aug 20 '26 18:08

San Jaisy


1 Answers

For the CLI, you can comma-delimit -D params.

java -jar tools/swagger-codegen-cli-3.0.34.jar generate \
  -i http://localhost:8080/swagger/fete-bird-api-gateway-0.0.yml \
  -l typescript-angular \
  -o libs/service/src/lib/swagger-specification \
  -Dmodels=true,modelDocs=false,modelTests=false \
  -c tools/angular-swagger-option.json

It is weird that the docs are wrong where. It's possible that they changed how they parsed options at one point. If you're interested in contributing to open source software, you could conceivably open a pull request to fix them!

like image 123
WildM Avatar answered Aug 22 '26 08:08

WildM