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 f7db2c68b..d8d6ecca9 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 @@ -24,6 +24,7 @@ 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.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; import com.google.common.base.Predicate; @@ -42,10 +43,13 @@ public class SwaggerConfig { private String description; private String contact; private List patterns; + private String basePath = ""; + private String documentationPath = "/"; @Bean public Docket gateApi() { return new Docket(DocumentationType.SWAGGER_2) + .pathProvider(new BasePathProvider(basePath, documentationPath)) .select() .apis(RequestHandlerSelectors.any()) .paths(paths()) @@ -90,4 +94,32 @@ public List getPatterns() { public void setPatterns(List patterns) { this.patterns = patterns; } + + public void setBasePath(String basePath) { this.basePath = basePath; } + + public String getBasePath() { return basePath; } + + public void setDocumentationPath(String documentationPath) { this.documentationPath = documentationPath; } + + public String getDocumentationPath() { return documentationPath; } + + public class BasePathProvider extends AbstractPathProvider { + private String basePath; + private String documentationPath; + + private BasePathProvider(String basePath, String documentationPath) { + this.basePath = basePath; + this.documentationPath = documentationPath; + } + + @Override + protected String applicationPath() { + return basePath; + } + + @Override + protected String getDocumentationPath() { + return documentationPath; + } + } }