Commit 2d93e7aeb3da856097db407952561354bc3899c8

Authored by RuoYi
1 parent 1a079532

swagger添加enable参数控制是否启用

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