swagger-api / swagger-api/swagger-codegen-generators
swagger-codegen 3.0.19 fail with NPE for jaxrs-jersey when use securitySchemes
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: []
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 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