swagger-api / swagger-api/swagger-codegen

Selective Generation doesn't work properly when option is appended

Open
#2,772 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Using version 2.1.6

Commands

java -Dmodels -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ -i http://petstore.swagger.io/v2/swagger.json \ -l java \ -o samples/client/petstore/java

And

java -Dmodels=User,Pet -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ -i http://petstore.swagger.io/v2/swagger.json \ -l java \ -o samples/client/petstore/java

work according to the documentation i.e. Example 1. generates all models only. Example 2 generates Pet and User models only.

However, if the -Dmodels option is appended on the end instead e.g.

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ -i http://petstore.swagger.io/v2/swagger.json \ -l java \ -o samples/client/petstore/java \ -Dmodels

Then for example 1. It will generate everything and for example 2. it will generate the first model in the list, so in this case, it will only generate the User model.

This is problematic as scripts which wrap java -jar /path/to/swagger-codegen-cli.jar such as homebrew install of swagger codegen don't allow the option to be passed in before -jar

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

Reproduce the two documented commands and the appended -Dmodels form using modules/swagger-codegen-cli/target/swagger-codegen-cli.jar. Trace how the CLI parses -Dmodels before and after -jar; done when both positions produce the same selected models, including all models when no value is supplied.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.