|
|
@@ -46,11 +46,19 @@ public class Swagger2Configuration extends WebMvcConfigurationSupport {
|
|
|
|
|
|
@Bean
|
|
|
public Docket createRestApi() {
|
|
|
+ // 新增:如果禁用,则返回一个禁用的Docket
|
|
|
+ return new Docket(DocumentationType.SWAGGER_2).enable(false);
|
|
|
+ /**
|
|
|
+ if (swaggerConfig.isDisable()) {
|
|
|
+ return new Docket(DocumentationType.SWAGGER_2)
|
|
|
+ .enable(false);
|
|
|
+ }
|
|
|
+
|
|
|
logger.debug("Starting Swagger");
|
|
|
logger.info("swaggerConfig ==> {}", swaggerConfig);
|
|
|
StopWatch watch = new StopWatch();
|
|
|
watch.start();
|
|
|
-
|
|
|
+
|
|
|
ApiSelectorBuilder builder = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).globalOperationParameters(getGlobalOperationParameters()).select();
|
|
|
builder.apis(basePackage(swaggerConfig.getBasePackage()));
|
|
|
builder.apis(RequestHandlerSelectors.withClassAnnotation(Api.class));
|
|
|
@@ -65,6 +73,7 @@ public class Swagger2Configuration extends WebMvcConfigurationSupport {
|
|
|
watch.stop();
|
|
|
logger.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
|
|
|
return docket;
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -136,8 +145,16 @@ public class Swagger2Configuration extends WebMvcConfigurationSupport {
|
|
|
|
|
|
@Override
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
+ // 如果禁用Swagger,则跳过资源注册
|
|
|
+ return;
|
|
|
+ /**
|
|
|
+ if (swaggerConfig.isDisable()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
|
|
|
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
|
|
+
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
// @Override
|