Skip to content

Commit

Permalink
OAS 3.1 - fix webhooks class scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
frantuma committed Jun 13, 2023
1 parent 70b17d9 commit 402b996
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.github.classgraph.ClassGraph;
import io.github.classgraph.ScanResult;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Webhooks;
import io.swagger.v3.oas.integration.api.OpenAPIConfiguration;
import io.swagger.v3.oas.integration.api.OpenApiScanner;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -70,6 +71,7 @@ public Set<Class<?>> classes() {
final Set<Class<?>> classes;
try (ScanResult scanResult = graph.scan()) {
classes = new HashSet<>(scanResult.getClassesWithAnnotation(OpenAPIDefinition.class.getName()).loadClasses());
classes.addAll(new HashSet<>(scanResult.getClassesWithAnnotation(Webhooks.class.getName()).loadClasses()));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Webhooks;
import io.swagger.v3.oas.integration.IgnoredPackages;
import io.swagger.v3.oas.integration.OpenApiConfigurationException;
import io.swagger.v3.oas.integration.SwaggerConfiguration;
Expand All @@ -21,7 +22,7 @@
*
* @since 2.1.2
*/
@HandlesTypes({Path.class, OpenAPIDefinition.class, ApplicationPath.class})
@HandlesTypes({Path.class, OpenAPIDefinition.class, ApplicationPath.class, Webhooks.class})
public class SwaggerServletInitializer implements ServletContainerInitializer {

static final Set<String> ignored = new HashSet();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.swagger.v3.jaxrs2.integration;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Webhooks;
import io.swagger.v3.oas.integration.IgnoredPackages;
import io.swagger.v3.oas.integration.OpenApiConfigurationException;
import io.swagger.v3.oas.integration.SwaggerConfiguration;
Expand All @@ -21,7 +22,7 @@
* swagger-jaxrs2-servlet-initializer-v2
*/
@Deprecated
@HandlesTypes({Path.class, OpenAPIDefinition.class, ApplicationPath.class})
@HandlesTypes({Path.class, OpenAPIDefinition.class, ApplicationPath.class, Webhooks.class})
public class SwaggerServletInitializer implements ServletContainerInitializer {

static final Set<String> ignored = new HashSet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.github.classgraph.ScanResult;
import io.swagger.v3.jaxrs2.integration.api.JaxrsOpenApiScanner;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Webhooks;
import io.swagger.v3.oas.integration.IgnoredPackages;
import io.swagger.v3.oas.integration.SwaggerConfiguration;
import io.swagger.v3.oas.integration.api.OpenAPIConfiguration;
Expand Down Expand Up @@ -93,6 +94,7 @@ public Set<Class<?>> classes() {
try (ScanResult scanResult = graph.scan()) {
classes = new HashSet<>(scanResult.getClassesWithAnnotation(javax.ws.rs.Path.class.getName()).loadClasses());
classes.addAll(new HashSet<>(scanResult.getClassesWithAnnotation(OpenAPIDefinition.class.getName()).loadClasses()));
classes.addAll(new HashSet<>(scanResult.getClassesWithAnnotation(Webhooks.class.getName()).loadClasses()));
if (Boolean.TRUE.equals(openApiConfiguration.isAlwaysResolveAppPath())) {
classes.addAll(new HashSet<>(scanResult.getClassesWithAnnotation(ApplicationPath.class.getName()).loadClasses()));
}
Expand Down

0 comments on commit 402b996

Please sign in to comment.