diff --git a/kork-swagger/kork-swagger.gradle b/kork-swagger/kork-swagger.gradle index 0ba8870b2..5d57e7d5c 100644 --- a/kork-swagger/kork-swagger.gradle +++ b/kork-swagger/kork-swagger.gradle @@ -7,7 +7,6 @@ dependencies { implementation "com.google.guava:guava" implementation "org.springframework.boot:spring-boot-autoconfigure" - implementation "io.springfox:springfox-swagger2" - implementation "io.springfox:springfox-swagger-ui" + implementation "io.springfox:springfox-boot-starter" } diff --git a/kork-swagger/src/main/java/com/netflix/spinnaker/config/SwaggerConfig.java b/kork-swagger/src/main/java/com/netflix/spinnaker/config/SwaggerConfig.java index 54823325c..662e45b2f 100644 --- a/kork-swagger/src/main/java/com/netflix/spinnaker/config/SwaggerConfig.java +++ b/kork-swagger/src/main/java/com/netflix/spinnaker/config/SwaggerConfig.java @@ -16,13 +16,10 @@ package com.netflix.spinnaker.config; -import static com.google.common.base.Predicates.or; - -import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; +import java.util.function.Predicate; import javax.annotation.Nullable; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -32,11 +29,9 @@ import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.ApiInfo; import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.AbstractPathProvider; +import springfox.documentation.spring.web.paths.DefaultPathProvider; import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; -@EnableSwagger2 @Configuration @ConditionalOnProperty("swagger.enabled") @ConfigurationProperties(prefix = "swagger") @@ -54,7 +49,7 @@ public class SwaggerConfig { @Bean public Docket gateApi() { return new Docket(DocumentationType.SWAGGER_2) - .pathProvider(new BasePathProvider(basePath, documentationPath)) + .pathProvider(new BasePathProvider(documentationPath)) .select() .apis(RequestHandlerSelectors.any()) .paths(paths()) @@ -80,7 +75,7 @@ private static Class getClassIfPresent(String name) { } private Predicate paths() { - return or(patterns.stream().map(PathSelectors::regex).collect(Collectors.toList())); + return patterns.stream().map(PathSelectors::regex).reduce((x, y) -> x.or(y)).get(); } private ApiInfo apiInfo() { @@ -123,20 +118,13 @@ public String getDocumentationPath() { return documentationPath; } - public class BasePathProvider extends AbstractPathProvider { - private String basePath; + public class BasePathProvider extends DefaultPathProvider { private String documentationPath; - private BasePathProvider(String basePath, String documentationPath) { - this.basePath = basePath; + private BasePathProvider(String documentationPath) { this.documentationPath = documentationPath; } - @Override - protected String applicationPath() { - return basePath; - } - @Override protected String getDocumentationPath() { return documentationPath; diff --git a/spinnaker-dependencies/spinnaker-dependencies.gradle b/spinnaker-dependencies/spinnaker-dependencies.gradle index 61a6ed9bf..9cc50add2 100644 --- a/spinnaker-dependencies/spinnaker-dependencies.gradle +++ b/spinnaker-dependencies/spinnaker-dependencies.gradle @@ -26,8 +26,8 @@ ext { spek2 : "2.0.9", springBoot : "2.5.15", springCloud : "2020.0.6", - springfoxSwagger : "2.9.2", - swagger : "1.5.20", //this should stay in sync with what springfoxSwagger expects + springfoxSwagger : "3.0.0", + swagger : "1.5.20", //this should stay in sync with what springfoxSwagger expects. // Spring boot 2.4.13 brings in 9.0.55. Spring boot 2.5.14 brings in // 9.0.63. Use 9.0.69 to resolve CVE-2022-42252 and CVE-2022-45143. Spring @@ -133,7 +133,7 @@ dependencies { api("de.huxhorn.sulky:de.huxhorn.sulky.ulid:8.2.0") api("dev.minutest:minutest:1.13.0") api("io.mockk:mockk:1.10.5") - api("io.springfox:springfox-swagger-ui:${versions.springfoxSwagger}") + api("io.springfox:springfox-boot-starter:${versions.springfoxSwagger}") api("io.springfox:springfox-swagger2:${versions.springfoxSwagger}") api("io.swagger:swagger-annotations:${versions.swagger}") api("javax.annotation:javax.annotation-api:1.3.2")