Selaa lähdekoodia

swagger不同环境加入设置,需不需要显示

gaodm 6 vuotta sitten
vanhempi
commit
22dff13f8f

+ 2 - 0
bi-service/src/main/java/com/diagbot/config/SwaggerConfigurer.java

@@ -1,6 +1,7 @@
 package com.diagbot.config;
 
 
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import springfox.documentation.builders.ApiInfoBuilder;
@@ -24,6 +25,7 @@ import java.util.List;
  * @time: 2018/8/2 14:21
  */
 @Configuration
+@ConditionalOnProperty(prefix = "swagger", value = {"enable"}, havingValue = "true")
 @EnableSwagger2
 public class SwaggerConfigurer {
     /**

+ 4 - 1
config-server/src/main/resources/shared/application-dev.yml

@@ -61,4 +61,7 @@ spring:
 #    devtools:
 #      restart:
 #        enabled: true #热部署生效
-#        additional-paths: src/main/java #设置重启的目录,添加那个目录的文件需要restart(监听目录)
+#        additional-paths: src/main/java #设置重启的目录,添加那个目录的文件需要restart(监听目录)
+
+swagger:
+  enable: true

+ 3 - 0
config-server/src/main/resources/shared/application-local.yml

@@ -62,3 +62,6 @@ spring:
 #      restart:
 #        enabled: true #热部署生效
 #        additional-paths: src/main/java #设置重启的目录,添加那个目录的文件需要restart(监听目录)
+
+swagger:
+  enable: true

+ 2 - 0
diagbotman-service/src/main/java/com/diagbot/config/SwaggerConfigurer.java

@@ -1,6 +1,7 @@
 package com.diagbot.config;
 
 
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import springfox.documentation.builders.ApiInfoBuilder;
@@ -24,6 +25,7 @@ import java.util.List;
  * @time: 2018/8/2 14:21
  */
 @Configuration
+@ConditionalOnProperty(prefix = "swagger", value = {"enable"}, havingValue = "true")
 @EnableSwagger2
 public class SwaggerConfigurer {
     /**

+ 2 - 0
feedback-service/src/main/java/com/diagbot/config/SwaggerConfigurer.java

@@ -1,6 +1,7 @@
 package com.diagbot.config;
 
 
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import springfox.documentation.builders.ApiInfoBuilder;
@@ -24,6 +25,7 @@ import java.util.List;
  * @time: 2018/8/2 14:21
  */
 @Configuration
+@ConditionalOnProperty(prefix = "swagger", value = {"enable"}, havingValue = "true")
 @EnableSwagger2
 public class SwaggerConfigurer {
     /**

+ 2 - 0
knowledge-service/src/main/java/com/diagbot/config/SwaggerConfigurer.java

@@ -1,6 +1,7 @@
 package com.diagbot.config;
 
 
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import springfox.documentation.builders.ApiInfoBuilder;
@@ -24,6 +25,7 @@ import java.util.List;
  * @time: 2018/8/2 14:21
  */
 @Configuration
+@ConditionalOnProperty(prefix = "swagger", value = {"enable"}, havingValue = "true")
 @EnableSwagger2
 public class SwaggerConfigurer {
     /**

+ 2 - 0
log-service/src/main/java/com/diagbot/config/SwaggerConfigurer.java

@@ -1,6 +1,7 @@
 package com.diagbot.config;
 
 
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import springfox.documentation.builders.ApiInfoBuilder;
@@ -24,6 +25,7 @@ import java.util.List;
  * @time: 2018/8/2 14:21
  */
 @Configuration
+@ConditionalOnProperty(prefix = "swagger", value = {"enable"}, havingValue = "true")
 @EnableSwagger2
 public class SwaggerConfigurer {
     /**

+ 4 - 2
user-service/src/main/java/com/diagbot/config/SwaggerConfigurer.java

@@ -13,6 +13,7 @@ import springfox.documentation.service.Parameter;
 import springfox.documentation.spi.DocumentationType;
 import springfox.documentation.spring.web.plugins.Docket;
 import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -24,6 +25,7 @@ import java.util.List;
  * @time: 2018/8/2 14:21
  */
 @Configuration
+@ConditionalOnProperty(prefix = "swagger", value = {"enable"}, havingValue = "true")
 @EnableSwagger2
 public class SwaggerConfigurer {
     /**
@@ -50,8 +52,8 @@ public class SwaggerConfigurer {
                 .apis(RequestHandlerSelectors.basePackage("com.diagbot.web"))
                 .paths(PathSelectors.any())
                 .build().globalOperationParameters(parameter());
-                //.securitySchemes(newArrayList(oauth()))
-               // .securityContexts(newArrayList(securityContext()));
+        //.securitySchemes(newArrayList(oauth()))
+        // .securityContexts(newArrayList(securityContext()));
     }
 
     private ApiInfo apiInfo() {