Skip to content
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

OpenAPIExtension's are not loaded by swagger-gradle-plugin #3726

Closed
aharin opened this issue Oct 29, 2020 · 2 comments · Fixed by #4626
Closed

OpenAPIExtension's are not loaded by swagger-gradle-plugin #3726

aharin opened this issue Oct 29, 2020 · 2 comments · Fixed by #4626
Assignees

Comments

@aharin
Copy link
Contributor

aharin commented Oct 29, 2020

swagger-gradle-plugin does not load io.swagger.v3.jaxrs2.ext.OpenAPIExtension classes.

The code in io.swagger.v3.jaxrs2.ext.OpenAPIExtensions uses ServiceLoader.load(OpenAPIExtension.class) to load extensions. The problem is that ServiceLoader uses Thread.currentThread().getContextClassLoader() when a ClassLoader is not specified which cannot see the META-INF\services files from within a gradle plugin.

Using ServiceLoader.load(OpenAPIExtension.class, OpenAPIExtensions.class.getClassLoader()) should load services correctly.

@aharin aharin changed the title OpenAPIExtension's are not loaded up by swagger-gradle-plugin OpenAPIExtension's are not loaded by swagger-gradle-plugin Oct 29, 2020
@frantuma frantuma self-assigned this Oct 29, 2020
@guai
Copy link

guai commented Feb 25, 2022

bump

@thefirstofthe300
Copy link
Contributor

I, too, am hitting this particular issue. I am attempting to use the Gradle plugin as a means of auto-generating the spec in order to provide an API diff on PRs. We use an OpenAPIExtension as a means of parsing our custom auth annotations and adding both the associated ApiResponse objects and the security scheme to the operation.

Being unable to generate the spec via the Gradle plugin means that diffing our API spec requires booting our Java application, querying the endpoint, and then generating a diff. Ultimately, it wastes several precious CI minutes on every PR commit's status checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants