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
Annotation inheritance from interfaces broken #2644
Comments
I've already crafted a test that stresses the bad logic and implemented the code fix. I will be submitting a pull request for this shortly. Just wanted to create this issue to document the problem and track work on it. |
frantuma
added a commit
that referenced
this issue
Feb 1, 2018
…ion_inheritance refs #2644 - 2.0 issue/interface annotation inheritance
Thanks for reporting and for the fix! Included in merged #2650, closing ticket, please reopen if you're still experiencing issues |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The class scanning logic in swagger-jaxrs2 does not properly process annotations which should be inherited from an interface.
The conditional here is the root cause of the issue:
swagger-core/modules/swagger-core/src/main/java/io/swagger/v3/core/util/ReflectionUtils.java
Line 305 in b1fd067
Since
annotations
is ultimately defined a few lines above as:swagger-core/modules/swagger-core/src/main/java/io/swagger/v3/core/util/ReflectionUtils.java
Line 292 in b1fd067
and Class#getAnnotationsByType(Class) defines it's return value to be:
the above condition will never be true, and implemented interfaces will never be scanned for annotations, even if no classes in the hierarchy contain any Swagger or jax-rs annotations.
The basic flow of the problem method is:
It appears as though it was a mere oversight that the second and third conditional do not check for an empty array in addition to null.
To sum things up:
Given this interface:
Observed behavior:
GET /resources
appears only under the default tag, and nowhere elseExpected behavior:
GET /resources
appears under the 'resource' tagThe text was updated successfully, but these errors were encountered: