swagger-api / swagger-api/swagger-codegen
[R] generation fails with a RuntimeException
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Trying to use swagger-codegen on this json to generate R code by doing
java -jar swagger-codegen-cli.jar generate -l r -o swagger_gen -i openapi.txt
I get the error
Exception in thread "Thread-1" java.lang.RuntimeException: Could not generate api file for 'Default'
at io.swagger.codegen.v3.DefaultGenerator.generateApis(DefaultGenerator.java:588)
at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:791)
at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:388)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at java.util.TreeMap.put(TreeMap.java:563)
at java.util.TreeSet.add(TreeSet.java:255)
at java.util.AbstractCollection.addAll(AbstractCollection.java:344)
at java.util.TreeSet.addAll(TreeSet.java:312)
at io.swagger.codegen.v3.DefaultGenerator.processOperations(DefaultGenerator.java:976)
at io.swagger.codegen.v3.DefaultGenerator.generateApis(DefaultGenerator.java:503)
... 3 more
The same json can be used to generate python code without issues
java -jar swagger-codegen-cli.jar generate -l python -o swagger_gen -i openapi.txt
Swagger-codegen version
3.0.35
Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen-cli.jar generate -l r -o swagger_gen -i openapi.txt
Steps to reproduce
Run the code below
wget https://github.com/swagger-api/swagger-codegen/files/9429783/openapi.txt
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.35/swagger-codegen-cli-3.0.35.jar -O swagger-codegen-cli.jar
java -jar swagger-codegen-cli.jar generate -l r -o swagger_gen -i openapi.txt
This will result in the error.
However doing
java -jar swagger-codegen-cli.jar generate -l python -o swagger_gen -i openapi.txt
will not
Related issues/PRs
#6995, #8482 Both appear to have the same error
Suggest a fix/enhancement
I am not familiar with what might be failing under the hood but trying other languages like python and java doesn't seem to be causing the same issue
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
Reproduce the failure with the supplied openapi.txt and the swagger-codegen 3.0.35 CLI command, then inspect DefaultGenerator.processOperations and generateApis around the reported stack-trace lines. Compare the R generation path with the successful Python command; done means the supplied input generates R code without the RuntimeException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, r
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100