Skip to content

Commit

Permalink
Minimize Swagger/OpenAPI dependencies in handler generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Dec 10, 2018
1 parent 731e47e commit 095b0ae
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Type, String> 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")))
Expand All @@ -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 ->
{
Expand All @@ -307,7 +305,7 @@ protected void addClassMethodHandlers(TypeSpec.Builder typeBuilder, Class<?> cla
});

final Map<Type, String> 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 ->
{
Expand Down Expand Up @@ -411,15 +409,15 @@ else if (t.equals(HttpServerExchange.class) || t.equals(ServerRequest.class))

List<String> 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);
}
}

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 095b0ae

Please sign in to comment.