Commit faf7e5b9 by 阳浪

SwaggerConfig

parent 6a419217
package com.yizhi.certificate.application; package com.yizhi.certificate.application;
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.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -27,6 +28,8 @@ import static springfox.documentation.builders.PathSelectors.regex; ...@@ -27,6 +28,8 @@ import static springfox.documentation.builders.PathSelectors.regex;
@EnableSwagger2 @EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurerAdapter { public class SwaggerConfig extends WebMvcConfigurerAdapter {
@Value("${swagger.enabled}")
private boolean swaggerEnabled;
/** /**
* 这个地方要重新注入一下资源文件,不然不会注入资源的,也没有注入requestHandlerMappping,相当于xml配置的 * 这个地方要重新注入一下资源文件,不然不会注入资源的,也没有注入requestHandlerMappping,相当于xml配置的
* <!--swagger资源配置--> * <!--swagger资源配置-->
...@@ -46,7 +49,7 @@ public class SwaggerConfig extends WebMvcConfigurerAdapter { ...@@ -46,7 +49,7 @@ public class SwaggerConfig extends WebMvcConfigurerAdapter {
@Bean @Bean
public Docket createRestApi() { public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2).enable(swaggerEnabled)
.groupName("证书服务") .groupName("证书服务")
.genericModelSubstitutes(DeferredResult.class) .genericModelSubstitutes(DeferredResult.class)
.genericModelSubstitutes(ResponseEntity.class) .genericModelSubstitutes(ResponseEntity.class)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment