swagger-api / swagger-api/swagger-codegen-generators

swagger-codegen 3.0.19 fail with NPE for jaxrs-jersey when use securitySchemes

Open
#682 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

I upgraded from Swagger 2.0 to OpenApi 3.x and ran into issues around Security Schemes. I defined securitySchemes bearer but it is failing with NPE when generating code around generators.DefaultCodegenConfig.fromSecurity .
I recreated the issue with a very simple YAML file.
It generates code fine from swagger UI hence something to do with code-gen used from CLI.

Steps to reproduce:
swagger-codegen generate -i provided_swagger.yaml -l jaxrs-jersey

Error:


Operation: pingGet
Resource: get /ping
Exception: null
at io.swagger.codegen.v3.DefaultGenerator.processOperation(DefaultGenerator.java:932)
at io.swagger.codegen.v3.DefaultGenerator.processPaths(DefaultGenerator.java:831)
at io.swagger.codegen.v3.DefaultGenerator.generateApis(DefaultGenerator.java:470)
at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:782)
at io.swagger.codegen.v3.cli.cmd.Generate.run(Generate.java:369)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at io.swagger.codegen.v3.generators.DefaultCodegenConfig.fromSecurity(DefaultCodegenConfig.java:2714)
at io.swagger.codegen.v3.DefaultGenerator.processOperation(DefaultGenerator.java:921)
... 5 more


Simplified Security Scheme usage :


securitySchemes:
bearer:
type: http
scheme: bearer

security:

  • bearer: []

security_issue_log.txt

openapi_security_issue.yaml.txt

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 with DefaultCodegenConfig.fromSecurity at the stack-trace location and reproduce the failure using openapi_security_issue.yaml.txt with the jaxrs-jersey generate command. Compare the securitySchemes and security entries with the generated output; done means generation completes without the NullPointerException for the provided YAML.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.