swagger-api / swagger-api/swagger-codegen

java.lang.NullPointerException

Open
#4,609 3 comments 0 reactions 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

Getting Exception in thread "main" java.lang.NullPointerException
at io.swagger.codegen.DefaultGenerator.generateParameterId(DefaultGenerator.java:832)
at io.swagger.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:756)
at io.swagger.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:725)
at io.swagger.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:354)
at io.swagger.codegen.DefaultGenerator.generate(DefaultGenerator.java:664)
at io.swagger.codegen.cmd.Generate.run(Generate.java:234)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:41)
when generating client python code from Master

Swagger-codegen version

Master

Swagger declaration file content or url

the spec is very long, I'll try to see if I can reduce its size, I suspect the ref "$ref": "#/paths/1api1v2~1services/post/responses/200/schema" in the response body
causes it.

Command line used for generation

java -jar ./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i ../swagger-combine/swagger.json -l python -o ../swagger-combine/test/

Steps to reproduce

just ran the above command.

Related issues

could not find any.

Suggest a Fix

Looks like https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java#L754 checks if path.getParameters() is not null but not if it does not contain null entries.

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 in modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java around generateParameterId and the path-parameter handling near line 754. Reproduce with the provided swagger-codegen-cli command and a reduced Swagger specification focused on the referenced response schema; done means Python client generation completes without the NullPointerException.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.