Make scanning all JAX-RS packages explicit #3283
Closed
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.
Description
The regression [1] has been reported by one of the CXF users with respect to
Swagger Core
releases after2.0.6
, here is the issue.The JAX-RS service has instance of the
Application
class which has only one resource class returned bygetClasses()
method. The service uses Swagger2.0.8
+ OpenAPI v3 and does not specify any resources classes and resource packages to scan (assuming those will be taken from theApplication
instance). Before2.0.7
it was the case but since than theSwagger Core
changed implementation fromReflections
toClassGraph
, and now always scan the complete class path if resource classes and resource packages are empty. The classes from theApplication
instance are added on top and there is no way to tailor this behavior.There are couple of solutions to make the behavior more controllable. The one presented in this PR is very simple but intuitive: introduce explicit marker to scan all packages.
Another option would be to check
Application
instance for resource classes and allow the scanning of all packages only if this set is empty.The feedback would be really appreciated, for now the desired results could be achieved with some smelly workarounds but it would be great to make the scanning outcomes obvious.
[1] https://issues.apache.org/jira/browse/CXF-8103
Thank you guys.
CC @frantuma