Skip to content

Commit 4f33008

Browse files
committed
Improve swagger docs
Hides the duplicate methods for the proxy endpoints.
1 parent f0b0247 commit 4f33008

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/main/java/eu/openanalytics/containerproxy/ContainerProxyApplication.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.logging.log4j.LogManager;
3838
import org.apache.logging.log4j.Logger;
3939
import org.bouncycastle.jce.provider.BouncyCastleProvider;
40+
import org.springdoc.core.GroupedOpenApi;
4041
import org.springframework.beans.factory.annotation.Autowired;
4142
import org.springframework.boot.SpringApplication;
4243
import org.springframework.boot.actuate.health.Health;
@@ -71,9 +72,12 @@
7172
import java.nio.file.Files;
7273
import java.nio.file.Paths;
7374
import java.security.Security;
75+
import java.util.Arrays;
76+
import java.util.HashSet;
7477
import java.util.List;
7578
import java.util.Objects;
7679
import java.util.Properties;
80+
import java.util.Set;
7781
import java.util.concurrent.Executor;
7882

7983
import static eu.openanalytics.containerproxy.api.ApiSecurityService.PROP_API_SECURITY_HIDE_SPEC_DETAILS;
@@ -345,4 +349,24 @@ private static void setDefaultProperties(SpringApplication app) {
345349
System.setProperty("jdk.serialSetFilterAfterRead", "true");
346350
}
347351

352+
@Bean
353+
public GroupedOpenApi groupOpenApi() {
354+
return GroupedOpenApi.builder()
355+
.group("v1")
356+
.addOpenApiCustomiser(openApi -> {
357+
Set<String> endpoints = new HashSet<>(Arrays.asList("/app_direct_i/**", "/app_direct/**", "/app_proxy/{proxyId}/**", "/error"));
358+
openApi.getPaths().entrySet().stream().filter(p -> endpoints.contains(p.getKey()))
359+
.forEach(p -> {
360+
p.getValue().setHead(null);
361+
p.getValue().setPost(null);
362+
p.getValue().setDelete(null);
363+
p.getValue().setParameters(null);
364+
p.getValue().setOptions(null);
365+
p.getValue().setPut(null);
366+
p.getValue().setPatch(null);
367+
});
368+
})
369+
.build();
370+
}
371+
348372
}

0 commit comments

Comments
 (0)