From 095b0aef63560fec2c5cf83887e801c2efe2db6c Mon Sep 17 00:00:00 2001 From: joshua bauer Date: Mon, 10 Dec 2018 11:43:07 -0800 Subject: [PATCH] Minimize Swagger/OpenAPI dependencies in handler generator. --- .../server/handlers/HandlerGenerator.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java b/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java index 02c1b55..bdf74d4 100644 --- a/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java +++ b/src/main/java/io/sinistral/proteus/server/handlers/HandlerGenerator.java @@ -56,8 +56,6 @@ import io.sinistral.proteus.server.ServerRequest; import io.sinistral.proteus.server.ServerResponse; import io.sinistral.proteus.server.endpoints.EndpointInfo; -import io.swagger.annotations.ApiOperation; -import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tags; import io.undertow.server.HandlerWrapper; @@ -267,7 +265,7 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla .addStatement("final $T router = new $T()", io.undertow.server.RoutingHandler.class, io.undertow.server.RoutingHandler.class); final Map parameterizedLiteralsNameMap = Arrays.stream(clazz.getDeclaredMethods()) - .filter(m -> m.getAnnotation(Operation.class) != null || m.getAnnotation(ApiOperation.class) != null) + .filter(m -> m.getAnnotation(Path.class) != null) .flatMap( m -> Arrays.stream(m.getParameters()).map(Parameter::getParameterizedType) .filter(t -> t.getTypeName().contains("<") && !t.getTypeName().contains("concurrent"))) @@ -282,7 +280,7 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla Arrays.stream(clazz.getDeclaredMethods()) - .filter(m -> m.getAnnotation(Operation.class) != null || m.getAnnotation(ApiOperation.class) != null) + .filter(m -> m.getAnnotation(Path.class) != null) .flatMap(m -> Arrays.stream(m.getParameters())) .forEach(p -> { @@ -307,7 +305,7 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class cla }); final Map literalsNameMap = Arrays.stream(clazz.getDeclaredMethods()) - .filter(m -> m.getAnnotation(Operation.class) != null || m.getAnnotation(ApiOperation.class) != null) + .filter(m -> m.getAnnotation(Path.class) != null) .flatMap(m -> Arrays.stream(m.getParameters()) .map(Parameter::getParameterizedType)).filter(t -> { @@ -411,15 +409,15 @@ else if (t.equals(HttpServerExchange.class) || t.equals(ServerRequest.class)) List typeLevelSecurityDefinitions = new ArrayList<>(); - if (Optional.ofNullable(clazz.getAnnotation(Tags.class)).isPresent()) + if (Optional.ofNullable(clazz.getAnnotation(Path.class)).isPresent()) { SecurityRequirement securityRequirementAnnotation = clazz.getAnnotation(SecurityRequirement.class); if(securityRequirementAnnotation != null) { - String securityRequirement = securityRequirementAnnotation.name(); + String securityRequirement = securityRequirementAnnotation.name(); - typeLevelSecurityDefinitions.add(securityRequirement); + typeLevelSecurityDefinitions.add(securityRequirement); } } @@ -881,7 +879,7 @@ else if (producesContentType.contains(MediaType.TEXT_HTML)) * @TODO wrap blocking in BlockingHandler */ - if (Optional.ofNullable(m.getAnnotation(Operation.class)).isPresent() || Optional.ofNullable(m.getAnnotation(ApiOperation.class)).isPresent()) + if (Optional.ofNullable(m.getAnnotation(Path.class)).isPresent()) { SecurityRequirement securityRequirementAnnotation = m.getAnnotation(SecurityRequirement.class);