5001: Add support for @Nullable annotations in OpenAPI 3.1 schemas#5018
5001: Add support for @Nullable annotations in OpenAPI 3.1 schemas#5018ewaostrowska merged 2 commits intoswagger-api:masterfrom
Conversation
| return schema.nullable(); | ||
| } | ||
| if (annotations != null) { | ||
| for (Annotation ann : annotations) { |
There was a problem hiding this comment.
is this loop needed?
if (annotations != null) {
return Arrays.stream(annotations).anyMatch(annotation ->
NULLABLE_ANNOTATIONS.contains(annotation.annotationType().getSimpleName()));
}
There was a problem hiding this comment.
Yes, it is. Not sure how to write it more elegant than this. Feel free to correct it, please if you prefer
There was a problem hiding this comment.
This version here removes redundancy. The loop variable ann was never used - it was just a mechanism to trigger the stream operation
|
@ronodhirSoumik will this PR make its way to the release? If so any eta? |
cab731b to
b93e8be
Compare
|
@zdary thanks for providing PR for this issue. As @ronodhirSoumik was suggesting the loop and stream was not necessary effective there so I have introduced a small change. Otherwise this is great :) Solves as well #4555 which community especially seemed to waiting for. It will make it to the next release. |
Pull Request
Thank you for contributing to swagger-core!
Please fill out the following information to help us review your PR efficiently.
Description
Enhanced schema generation by recognizing
Introduced a test case to validate the behavior and ensure backward compatibility with explicit @Schema annotations.
Fixes: #5001 , #4555
Type of Change
Checklist
Screenshots / Additional Context