[BUG] NPE in DefaultGenerator.getOAuthMethods
Created by: kymbalon
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? - [x ] Have you validated the input using an OpenAPI validator (example)?
- [x ] What's the version of OpenAPI Generator used?
- [x ] Have you search for related issues/PRs?
- [x ] What's the actual output vs expected output?
-
[Optional] Bounty to sponsor the fix (example)
Description
DefaultGenerator.getOAuthMethods iterates a list of CodegenSecurity querying the Boolean (object) isOAuth without checking it for null. Maybe there are similar places in the code where Boolean variables should be double-checked (or auto-boxed).
openapi-generator version
4.0.0-beta2
OpenAPI declaration file content or url
components:
securitySchemes:
BasicAuth:
type: http
scheme: basic
BearerAuth:
type: http
scheme: bearer
ApiKeyAuth:
type: apiKey
in: header
name: X-API-Key
OpenID:
type: openIdConnect
openIdConnectUrl: https://example.com/.well-known/openid-configuration
OAuth2:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://example.com/oauth/authorize
tokenUrl: https://example.com/oauth/token
scopes:
read: Grants read access
write: Grants write access
admin: Grants access to admin operations
Command line used for generation
Steps to reproduce
API spec with at least one securityScheme which is not OAuth2.
Related issues/PRs
Other issues concerning NPEs might be related.
Suggest a fix
for (CodegenSecurity cs : authMethods) {
if (Boolean.TRUE.equals(cs.isOAuth)) {
oauthMethods.add(cs);
}
}