swagger-api / swagger-api/swagger-codegen
Swagger Codegen CLI swallows RuntimeException, always returns success (0) exit code.
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Swagger Codegen CLI is swallowing all RuntimeExceptions thrown throughout the tool, and returns a success exit status (0). This makes it impossible to determine if errors occurred on our CI jobs while generating code.
Swagger-codegen version
3.0.20
current HEAD of 3.0.0 branch.
Swagger declaration file content or url
Any spec - simply use an invalid handlebar template to trigger a RuntimeException.
Command line used for generation
java -classpath <swagger jars> -l swift -i <my.yaml> -o <anywhere> -c <my-configuration.json>
Steps to reproduce
Simply use invalid handlebar template to trigger a RuntimeException, run the tool, and then run the following (zsh example)
echo $?
It will print 0 even though runtime exception occurred.
Related issues/PRs
The following appear to have same or similar root cause:
10434, 6832, 1140
Suggest a fix/enhancement
At these lines here, where swallowing Exception, simply add:
System.exit(<Error code, greater than 0, that identifies an error occurred>)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at modules/swagger-codegen/src/main/java/io/swagger/codegen/Codegen.java, especially lines 109-120 where the RuntimeException is swallowed. Reproduce the failure with an invalid Handlebars template using the documented CLI command, then verify that echo $? reports a nonzero status when generation fails.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- handlebars, java
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100