NPE occurs when outputting an OpenAPI document since 2.5.0 #2561
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NPE occurs when outputting an OpenAPI document in a project using springdoc-openapi 2.5.0.
It appears to occur only when certain annotations are included.
Specifically controller class with
@Header
annotation include@Schema
attribute set.To Reproduce
Steps to reproduce the behavior:
Expected behavior
NPE does not happen, can get JSON response.
Additional context
Swagger-core have been added
getHeader
overload methods intoAnnotationsUtils
.This change seems to have been made between
2.2.20
and2.2.21
.swagger-api/swagger-core@v2.2.20...v2.2.21
Around here that is added.
https://github.com/swagger-api/swagger-core/blame/d5c37284f5dbb9b6e65858c25d55c1aa2969f8a2/modules/swagger-core/src/main/java/io/swagger/v3/core/util/AnnotationsUtils.java#L1290-L1326
If we do not pass components, it will be thrown NPE here.
https://github.com/swagger-api/swagger-core/blob/d5c37284f5dbb9b6e65858c25d55c1aa2969f8a2/modules/swagger-core/src/main/java/io/swagger/v3/core/util/AnnotationsUtils.java#L1387