diff --git a/src/main/java/io/linfeng/config/SwaggerConfig.java b/src/main/java/io/linfeng/config/SwaggerConfig.java index a8f01b8..c88502f 100644 --- a/src/main/java/io/linfeng/config/SwaggerConfig.java +++ b/src/main/java/io/linfeng/config/SwaggerConfig.java @@ -11,6 +11,7 @@ */ package io.linfeng.config; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -31,10 +32,15 @@ import java.util.List; @EnableSwagger2 public class SwaggerConfig implements WebMvcConfigurer { + @Value("${linfeng.swagger.enable}") + private Boolean enable; + + @Bean public Docket createRestApi(){ return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) + .enable(enable) .select() .apis(RequestHandlerSelectors.basePackage("io.linfeng")) .paths(PathSelectors.any()) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index faf5c15..04d1b81 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -34,6 +34,10 @@ spring: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8 +linfeng: + swagger: + enable: true + logging: level: io.linfeng: DEBUG diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 897472a..6beb59d 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -32,6 +32,10 @@ spring: config: multi-statement-allow: true +linfeng: + swagger: + enable: false + logging: level: io.linfeng: Info