swagger-api / swagger-api/swagger-codegen

Nullpointer exception in swagger-codegen with java

Open
#8,348 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

When trying to do java codegen with swagger cli, I'm getting a NPE
Swagger json is valid one, has validated using swagger UI

Error log

Exception in thread "Thread-1" java.lang.NullPointerException
at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:849)
at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:827)
at io.swagger.v3.parser.converter.SwaggerConverter.lambda$convert$11(SwaggerConverter.java:1049)
at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:1048)
at io.swagger.v3.parser.converter.SwaggerConverter.convert(SwaggerConverter.java:212)
at io.swagger.v3.parser.converter.SwaggerConverter.readLocation(SwaggerConverter.java:90)
at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:19)
at io.swagger.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:433)
at io.swagger.codegen.cmd.Generate.run(Generate.java:310)
at java.lang.Thread.run(Thread.java:748)

Swagger-codegen version

Tried in both 3.0.0-rc0 and 3.0.0-rc1

Swagger declaration file content or url

Sorry, the swagger cannot be pasted here due to privacy reasons

Command line used for generation

I have downloaded the swagger file as a json into my local filesystem
$ java -jar swagger-codegen-cli.jar generate -i swagger.json -l java -o /tmp

Steps to reproduce

Downloaded the 3.0.0-rc0 and 3.0.0-rc1 sources from github, and did a local build in Mac, to get the swagger-codegen-cli binary
Then executed following
$ java -jar swagger-codegen-cli.jar generate -i swagger.json -l java -o /tmp

Related issues/PRs
Suggest a fix/enhancement

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

Start at SwaggerConverter.java:849 and trace the call from CodegenConfigurator.toClientOptInput in the reported CLI command. Reproduce with the same swagger.json if it can be obtained; completion means Java generation no longer throws the reported NullPointerException, but the private declaration currently prevents direct reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.