-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed process nullable annotations #923
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loogs good to me, maybe pattern matching (like *.Nullable
) could be considered but that could have unintended side effects in very rare cases. But that's up to you / just an idea
openapi/src/main/java/io/micronaut/openapi/visitor/AbstractOpenApiVisitor.java
Show resolved
Hide resolved
|| element.getType().isOptional() | ||
|| element.hasStereotype(Nullable.class) | ||
|| element.hasStereotype("jakarta.annotation.Nullable") | ||
|| element.hasStereotype("org.jetbrains.annotations.Nullable"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider supporting other nullability annotations https://kotlinlang.org/docs/java-interop.html#nullability-annotations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be implemented using an annotation transformer to transform the annotations to AnnotationUtil.NULLABLE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add all other annotations too
openapi/src/test/groovy/io/micronaut/openapi/visitor/OpenApiNullableTypesSpec.groovy
Outdated
Show resolved
Hide resolved
openapi/src/main/java/io/micronaut/openapi/visitor/AbstractOpenApiVisitor.java
Outdated
Show resolved
Hide resolved
cc9877b
to
2545aa3
Compare
@sdelamo @dstepanov I've added support all nullable annotations from @sdelamo 's link. But I think i found bug in micronaut:
These two annotations not found. I think problem is here: both annotions have Target TYPE_USE
|
return element.isNullable() | ||
|| element.getType().isOptional() | ||
|| element.hasStereotype(Nullable.class) | ||
|| element.hasStereotype("javax.annotation.Nullable") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dstepanov No, can't. Because it since micronaut 4.0, but this fix for release 4.8.3 which based on micronaut 3.8.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should work in 3.8.3 too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dstepanov no! this class added in micronaut 4.0:
Can't find this class in 3.8.x branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the class is just an example how to do it. Just copy it, modify the annotation name and define it in the service entires.
@altro3 Javac might be acting strange with those types. Maybe you can create an issue with a reproducible test in the core? |
Fixed #921