From b7d5cf62ae04d86d0d33223a1d45bf33618e77e5 Mon Sep 17 00:00:00 2001 From: joshua bauer Date: Mon, 22 Oct 2018 11:26:25 -0700 Subject: [PATCH] Properly handle empty responses in OpenAPI. --- .../sinistral/proteus/server/tools/oas/Reader.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/sinistral/proteus/server/tools/oas/Reader.java b/src/main/java/io/sinistral/proteus/server/tools/oas/Reader.java index 35a4c65..093fc9e 100644 --- a/src/main/java/io/sinistral/proteus/server/tools/oas/Reader.java +++ b/src/main/java/io/sinistral/proteus/server/tools/oas/Reader.java @@ -1348,12 +1348,14 @@ else if (classType.getRawClass().isAssignableFrom(CompletableFuture.class)) } if (operation.getResponses() == null || operation.getResponses().isEmpty()) { - Content content = new Content(); - MediaType mediaType = new MediaType(); - AnnotationsUtils.applyTypes(classProduces == null ? new String[0] : classProduces.value(), - methodProduces == null ? new String[0] : methodProduces.value(), content, mediaType); + LOGGER.debug("responses are null or empty"); + + //Content content = new Content(); + //MediaType mediaType = new MediaType(); + //AnnotationsUtils.applyTypes(classProduces == null ? new String[0] : classProduces.value(), + // methodProduces == null ? new String[0] : methodProduces.value(), content, mediaType); - ApiResponse apiResponseObject = new ApiResponse().description(DEFAULT_DESCRIPTION).content(content); + ApiResponse apiResponseObject = new ApiResponse().description(DEFAULT_DESCRIPTION);//.content(content); operation.setResponses(new ApiResponses()._default(apiResponseObject)); } @@ -1495,7 +1497,7 @@ private void setOperationObjectFromApiOperationAnnotation( operation.setResponses(responses); } else - { + { responses.forEach(operation.getResponses()::addApiResponse); } });