From 60676acc59418fbb5a9e881b830318dd0af7fa1d Mon Sep 17 00:00:00 2001 From: Thomas Bayer Date: Mon, 11 Mar 2024 14:57:15 +0100 Subject: [PATCH] Review --- .../core/openapi/serviceproxy/ApiDocsInterceptor.java | 10 ++-------- .../openapi/serviceproxy/ApiDocsInterceptorTest.java | 3 +-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/ApiDocsInterceptor.java b/core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/ApiDocsInterceptor.java index be7a8ad90a..04da129bff 100644 --- a/core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/ApiDocsInterceptor.java +++ b/core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/ApiDocsInterceptor.java @@ -55,7 +55,7 @@ public Map initializeRuleApiSpecs() { .collect(Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue, - (key1, key2) -> key1, // If duplicate keys, keep the first one + (key1, ignored) -> key1, // If duplicate keys, keep the first one LinkedHashMap::new )); } @@ -78,13 +78,7 @@ private boolean hasOpenAPIInterceptor(Rule rule) { Optional getOpenAPIInterceptor(Rule rule) { return rule.getInterceptors().stream() .filter(ic -> ic instanceof OpenAPIInterceptor) - .map(ic -> (OpenAPIInterceptor) ic) + .map(ic -> (OpenAPIInterceptor) ic) // Previous line checks type, so cast should be fine .findFirst(); } - - private boolean acceptsHtmlExplicit(Exchange exc) { - if (exc.getRequest().getHeader().getAccept() == null) - return false; - return exc.getRequest().getHeader().getAccept().contains("html"); - } } diff --git a/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/ApiDocsInterceptorTest.java b/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/ApiDocsInterceptorTest.java index 10477db0b3..a7f1bffaa3 100644 --- a/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/ApiDocsInterceptorTest.java +++ b/core/src/test/java/com/predic8/membrane/core/openapi/serviceproxy/ApiDocsInterceptorTest.java @@ -53,7 +53,6 @@ public void setUp() throws Exception { interceptor = new ApiDocsInterceptor(); interceptor.init(router); - } @AfterEach @@ -98,7 +97,7 @@ public void getHTMLOverview() throws Exception { public void getSwaggerUI() throws Exception { exc.getRequest().setUri("/api-docs/ui/fruit-shop-api-v2-0-0"); assertEquals(RETURN, interceptor.handleRequest(exc)); - assertTrue(exc.getResponse().getBodyAsStringDecoded().contains("html")); + assertTrue(exc.getResponse().getBodyAsStringDecoded().contains("Swagger")); } @Test