Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
predic8 committed Mar 11, 2024
1 parent 4027000 commit 60676ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Map<String, OpenAPIRecord> 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
));
}
Expand All @@ -78,13 +78,7 @@ private boolean hasOpenAPIInterceptor(Rule rule) {
Optional<OpenAPIInterceptor> 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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public void setUp() throws Exception {

interceptor = new ApiDocsInterceptor();
interceptor.init(router);

}

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

0 comments on commit 60676ac

Please sign in to comment.