新增swagger开关配置

This commit is contained in:
linfeng 2023-12-26 09:11:48 +08:00
parent a9549d76f3
commit d40760adc5
3 changed files with 14 additions and 0 deletions

View File

@ -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())

View File

@ -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

View File

@ -32,6 +32,10 @@ spring:
config:
multi-statement-allow: true
linfeng:
swagger:
enable: false
logging:
level:
io.linfeng: Info