swagger是否生成文档改成配置文件

This commit is contained in:
wulin 2020-11-27 14:17:54 +08:00
parent 11eed02309
commit 23a78f0756
5 changed files with 10 additions and 3 deletions

View File

@ -9,6 +9,7 @@
package com.lz.config; package com.lz.config;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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;
@ -29,10 +30,13 @@ import static com.google.common.collect.Lists.newArrayList;
@EnableSwagger2 @EnableSwagger2
public class SwaggerConfig implements WebMvcConfigurer { public class SwaggerConfig implements WebMvcConfigurer {
@Value(value = "${swagger.enable}")
boolean enableSwagger;
@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(enableSwagger)
.select() .select()
//加了ApiOperation注解的类才生成接口文档 //加了ApiOperation注解的类才生成接口文档
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))

View File

@ -267,8 +267,6 @@ public class DingtalkBusiness {
integer.setMemberCount(integer.getMemberCount() + staffs.size()); integer.setMemberCount(integer.getMemberCount() + staffs.size());
} }
if(staffs.size() > 0){ if(staffs.size() > 0){
for (DepartmentStaffBo departmentStaffBo:staffs for (DepartmentStaffBo departmentStaffBo:staffs
) { ) {

View File

@ -37,6 +37,8 @@ domain:
main: "http://192.168.43.94:8001" main: "http://192.168.43.94:8001"
sms: sms:
code: false code: false
swagger:
enable: true
##多数据源的配置 ##多数据源的配置
#dynamic: #dynamic:

View File

@ -36,6 +36,8 @@ domain:
main: "https://lzmanagement.ldxinyong.com" main: "https://lzmanagement.ldxinyong.com"
sms: sms:
code: true code: true
swagger:
enable: true
##多数据源的配置 ##多数据源的配置
#dynamic: #dynamic:
# datasource: # datasource:

View File

@ -36,7 +36,8 @@ domain:
main: "http:/localhost" main: "http:/localhost"
sms: sms:
code: false code: false
swagger:
enable: true
##多数据源的配置 ##多数据源的配置
#dynamic: #dynamic: