新增swagger开关配置
This commit is contained in:
parent
a9549d76f3
commit
d40760adc5
@ -11,6 +11,7 @@
|
|||||||
*/
|
*/
|
||||||
package io.linfeng.config;
|
package io.linfeng.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
@ -31,10 +32,15 @@ import java.util.List;
|
|||||||
@EnableSwagger2
|
@EnableSwagger2
|
||||||
public class SwaggerConfig implements WebMvcConfigurer {
|
public class SwaggerConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Value("${linfeng.swagger.enable}")
|
||||||
|
private Boolean enable;
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Docket createRestApi(){
|
public Docket createRestApi(){
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
.apiInfo(apiInfo())
|
.apiInfo(apiInfo())
|
||||||
|
.enable(enable)
|
||||||
.select()
|
.select()
|
||||||
.apis(RequestHandlerSelectors.basePackage("io.linfeng"))
|
.apis(RequestHandlerSelectors.basePackage("io.linfeng"))
|
||||||
.paths(PathSelectors.any())
|
.paths(PathSelectors.any())
|
||||||
|
@ -34,6 +34,10 @@ spring:
|
|||||||
date-format: yyyy-MM-dd HH:mm:ss
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
time-zone: GMT+8
|
time-zone: GMT+8
|
||||||
|
|
||||||
|
linfeng:
|
||||||
|
swagger:
|
||||||
|
enable: true
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
io.linfeng: DEBUG
|
io.linfeng: DEBUG
|
||||||
|
@ -32,6 +32,10 @@ spring:
|
|||||||
config:
|
config:
|
||||||
multi-statement-allow: true
|
multi-statement-allow: true
|
||||||
|
|
||||||
|
linfeng:
|
||||||
|
swagger:
|
||||||
|
enable: false
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
io.linfeng: Info
|
io.linfeng: Info
|
||||||
|
Loading…
Reference in New Issue
Block a user