From 0fea1e02d93c8ad58d626d18a20c4a4c499eefbe Mon Sep 17 00:00:00 2001 From: zlt2000 Date: Mon, 10 Aug 2020 14:39:25 +0800 Subject: [PATCH] =?UTF-8?q?swagger-ui=E6=9B=BF=E6=8D=A2=E4=B8=BAknife4j?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 11 +++++++++++ .../common/properties/PermitProperties.java | 1 + .../zlt-swagger2-spring-boot-starter/pom.xml | 8 ++------ .../common/swagger2/Swagger2Configuration.java | 17 ----------------- .../swagger2/SwaggerAutoConfiguration.java | 15 +++++++++++---- zlt-gateway/sc-gateway/pom.xml | 8 ++------ zlt-gateway/zuul-gateway/pom.xml | 10 ---------- 7 files changed, 27 insertions(+), 43 deletions(-) delete mode 100644 zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/Swagger2Configuration.java diff --git a/pom.xml b/pom.xml index b3ff0dd..d93adc8 100644 --- a/pom.xml +++ b/pom.xml @@ -50,6 +50,7 @@ 4.0.1 3.2.7.RELEASE 7.8.0 + 2.0.4 1.2.2 zlt-job/**/*, zlt-register/**/*, zlt-web/**/* openjdk:8-jre-alpine @@ -358,6 +359,16 @@ elasticsearch ${elasticsearch.version} + + com.github.xiaoymin + knife4j-spring-boot-starter + ${knife4j.version} + + + com.github.xiaoymin + knife4j-micro-spring-boot-starter + ${knife4j.version} + org.springframework.boot diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/PermitProperties.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/PermitProperties.java index 16a5b65..e0c3c15 100644 --- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/PermitProperties.java +++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/PermitProperties.java @@ -23,6 +23,7 @@ public class PermitProperties { "/*/v2/api-docs", "/swagger/api-docs", "/swagger-ui.html", + "/doc.html", "/swagger-resources/**", "/webjars/**", "/druid/**" diff --git a/zlt-commons/zlt-swagger2-spring-boot-starter/pom.xml b/zlt-commons/zlt-swagger2-spring-boot-starter/pom.xml index b8e75cf..2c8f2cb 100644 --- a/zlt-commons/zlt-swagger2-spring-boot-starter/pom.xml +++ b/zlt-commons/zlt-swagger2-spring-boot-starter/pom.xml @@ -17,12 +17,8 @@ spring-boot-starter - io.springfox - springfox-swagger-ui - - - io.springfox - springfox-swagger2 + com.github.xiaoymin + knife4j-micro-spring-boot-starter org.springframework.boot diff --git a/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/Swagger2Configuration.java b/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/Swagger2Configuration.java deleted file mode 100644 index 2903d4c..0000000 --- a/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/Swagger2Configuration.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.central.common.swagger2; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Import; -import springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration; - -/** - * - * @author zlt - * @date 2018/11/18 9:20 - */ -@ConditionalOnProperty(name = "zlt.swagger.enabled", matchIfMissing = true) -@Import({ - Swagger2DocumentationConfiguration.class -}) -public class Swagger2Configuration { -} diff --git a/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/SwaggerAutoConfiguration.java b/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/SwaggerAutoConfiguration.java index 09e20d3..0919f96 100644 --- a/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/SwaggerAutoConfiguration.java +++ b/zlt-commons/zlt-swagger2-spring-boot-starter/src/main/java/com/central/common/swagger2/SwaggerAutoConfiguration.java @@ -1,16 +1,18 @@ package com.central.common.swagger2; +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.Lists; -import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; +import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ParameterBuilder; import springfox.documentation.builders.PathSelectors; @@ -25,6 +27,7 @@ import springfox.documentation.service.SecurityReference; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.service.contexts.SecurityContext; import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; import java.util.ArrayList; import java.util.LinkedList; @@ -36,10 +39,14 @@ import java.util.stream.Collectors; /** * @author zlt * @date 2018/11/18 9:22 + *

+ * Blog: https://zlt2000.gitee.io + * Github: https://github.com/zlt2000 */ -@Import( { - Swagger2Configuration.class -}) +@Configuration +@EnableSwagger2 +@EnableKnife4j +@Import(BeanValidatorPluginsConfiguration.class) public class SwaggerAutoConfiguration implements BeanFactoryAware { private static final String AUTH_KEY = "Authorization"; diff --git a/zlt-gateway/sc-gateway/pom.xml b/zlt-gateway/sc-gateway/pom.xml index 8b5533a..bd9dee0 100644 --- a/zlt-gateway/sc-gateway/pom.xml +++ b/zlt-gateway/sc-gateway/pom.xml @@ -69,12 +69,8 @@ - io.springfox - springfox-swagger2 - - - io.springfox - springfox-swagger-ui + com.github.xiaoymin + knife4j-spring-boot-starter diff --git a/zlt-gateway/zuul-gateway/pom.xml b/zlt-gateway/zuul-gateway/pom.xml index 955ac14..8153903 100644 --- a/zlt-gateway/zuul-gateway/pom.xml +++ b/zlt-gateway/zuul-gateway/pom.xml @@ -72,16 +72,6 @@ swagger-butler-core - - com.github.xiaoymin - swagger-bootstrap-ui - - - - com.zyplayer - swagger-mg-ui - - org.springframework.cloud spring-cloud-starter-netflix-zuul -- GitLab