Commit 2d93e7aeb3da856097db407952561354bc3899c8
1 parent
1a079532
swagger添加enable参数控制是否启用
Showing
3 changed files
with
12 additions
and
1 deletions
ruoyi/sql/ry_20200415.sql
| @@ -138,7 +138,7 @@ create table sys_menu ( | @@ -138,7 +138,7 @@ create table sys_menu ( | ||
| 138 | is_frame int(1) default 1 comment '是否为外链(0是 1否)', | 138 | is_frame int(1) default 1 comment '是否为外链(0是 1否)', |
| 139 | menu_type char(1) default '' comment '菜单类型(M目录 C菜单 F按钮)', | 139 | menu_type char(1) default '' comment '菜单类型(M目录 C菜单 F按钮)', |
| 140 | visible char(1) default 0 comment '菜单状态(0显示 1隐藏)', | 140 | visible char(1) default 0 comment '菜单状态(0显示 1隐藏)', |
| 141 | - status char(1) not null comment '菜单状态(0正常 1停用)', | 141 | + status char(1) default 0 comment '菜单状态(0正常 1停用)', |
| 142 | perms varchar(100) default null comment '权限标识', | 142 | perms varchar(100) default null comment '权限标识', |
| 143 | icon varchar(100) default '#' comment '菜单图标', | 143 | icon varchar(100) default '#' comment '菜单图标', |
| 144 | create_by varchar(64) default '' comment '创建者', | 144 | create_by varchar(64) default '' comment '创建者', |
ruoyi/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java
| @@ -3,6 +3,7 @@ package com.ruoyi.framework.config; | @@ -3,6 +3,7 @@ package com.ruoyi.framework.config; | ||
| 3 | import java.util.ArrayList; | 3 | import java.util.ArrayList; |
| 4 | import java.util.List; | 4 | import java.util.List; |
| 5 | import org.springframework.beans.factory.annotation.Autowired; | 5 | import org.springframework.beans.factory.annotation.Autowired; |
| 6 | +import org.springframework.beans.factory.annotation.Value; | ||
| 6 | import org.springframework.context.annotation.Bean; | 7 | import org.springframework.context.annotation.Bean; |
| 7 | import org.springframework.context.annotation.Configuration; | 8 | import org.springframework.context.annotation.Configuration; |
| 8 | import io.swagger.annotations.ApiOperation; | 9 | import io.swagger.annotations.ApiOperation; |
| @@ -32,6 +33,10 @@ public class SwaggerConfig | @@ -32,6 +33,10 @@ public class SwaggerConfig | ||
| 32 | @Autowired | 33 | @Autowired |
| 33 | private RuoYiConfig ruoyiConfig; | 34 | private RuoYiConfig ruoyiConfig; |
| 34 | 35 | ||
| 36 | + /** Swagger开关配置 */ | ||
| 37 | + @Value("${swagger.enable}") | ||
| 38 | + private boolean swaggerEnable; | ||
| 39 | + | ||
| 35 | /** | 40 | /** |
| 36 | * 创建API | 41 | * 创建API |
| 37 | */ | 42 | */ |
| @@ -39,6 +44,8 @@ public class SwaggerConfig | @@ -39,6 +44,8 @@ public class SwaggerConfig | ||
| 39 | public Docket createRestApi() | 44 | public Docket createRestApi() |
| 40 | { | 45 | { |
| 41 | return new Docket(DocumentationType.SWAGGER_2) | 46 | return new Docket(DocumentationType.SWAGGER_2) |
| 47 | + // 是否启用Swagger | ||
| 48 | + .enable(swaggerEnable) | ||
| 42 | .pathMapping("/dev-api") | 49 | .pathMapping("/dev-api") |
| 43 | // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) | 50 | // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) |
| 44 | .apiInfo(apiInfo()) | 51 | .apiInfo(apiInfo()) |
ruoyi/src/main/resources/application.yml
| @@ -100,6 +100,10 @@ pagehelper: | @@ -100,6 +100,10 @@ pagehelper: | ||
| 100 | supportMethodsArguments: true | 100 | supportMethodsArguments: true |
| 101 | params: count=countSql | 101 | params: count=countSql |
| 102 | 102 | ||
| 103 | +# Swagger配置 | ||
| 104 | +swagger: | ||
| 105 | + enable: true | ||
| 106 | + | ||
| 103 | # 防止XSS攻击 | 107 | # 防止XSS攻击 |
| 104 | xss: | 108 | xss: |
| 105 | # 过滤开关 | 109 | # 过滤开关 |