swagger-api / swagger-api/swagger-codegen
Generate service with -l jaxrs-spec fails with NPE
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I downloaded one of the latest 3.0 snapshot builds and tried to generate with -l jaxrs-spec, but I got an NPE
Exception in thread "Thread-1" java.lang.NullPointerException
at io.swagger.codegen.languages.AbstractJavaJAXRSServerCodegen.preprocessOpenAPI(AbstractJavaJAXRSServerCodegen.java:107)
at io.swagger.codegen.languages.JavaJAXRSSpecServerCodegen.preprocessOpenAPI(JavaJAXRSSpecServerCodegen.java:161)
at io.swagger.codegen.DefaultGenerator.configureGeneratorProperties(DefaultGenerator.java:199)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:715)
at io.swagger.codegen.cmd.Generate.run(Generate.java:312)
at java.lang.Thread.run(Thread.java:745)
Swagger-codegen version
swagger-codegen-cli-3.0.0-20180111.055017-19.jar
Swagger declaration file content or url
Use any v3 json or yaml sample
Command line used for generation
java -jar swagger-codegen-cli-3.0.0-20180111.055017-19.jar generate -i petstore3.json -l jaxrs-spec
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
In AbstractJavaJAXRSServerCodegen, should consider that an operation contained within the operations array can be null.
When creating the operations array with ModelUtils.createOperationArray(pathItem); and passing in only one pathitem, then it will be expected that some of the operations will be null.
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 in AbstractJavaJAXRSServerCodegen.preprocessOpenAPI at the stack-trace line, then inspect JavaJAXRSSpecServerCodegen and ModelUtils.createOperationArray(pathItem). Reproduce with the supplied generate command and petstore3.json or another OpenAPI v3 sample; done means -l jaxrs-spec completes without the reported NullPointerException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100