update 升级 swagger 配置 使用 knife4j 增强模式
This commit is contained in:
parent
6904f38ea2
commit
53cb0826bc
3
pom.xml
3
pom.xml
@ -350,6 +350,7 @@
|
||||
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
||||
<profiles.active>local</profiles.active>
|
||||
<logging.level>debug</logging.level>
|
||||
<knife4j.production>false</knife4j.production>
|
||||
<endpoints.include>'*'</endpoints.include>
|
||||
</properties>
|
||||
</profile>
|
||||
@ -359,6 +360,7 @@
|
||||
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
||||
<profiles.active>dev</profiles.active>
|
||||
<logging.level>debug</logging.level>
|
||||
<knife4j.production>false</knife4j.production>
|
||||
<endpoints.include>'*'</endpoints.include>
|
||||
</properties>
|
||||
<activation>
|
||||
@ -371,6 +373,7 @@
|
||||
<properties>
|
||||
<profiles.active>prod</profiles.active>
|
||||
<logging.level>warn</logging.level>
|
||||
<knife4j.production>true</knife4j.production>
|
||||
<endpoints.include>health, info, logfile</endpoints.include>
|
||||
</properties>
|
||||
</profile>
|
||||
|
@ -214,6 +214,22 @@ swagger:
|
||||
- name: 3.代码生成模块
|
||||
basePackage: com.ruoyi.generator
|
||||
|
||||
knife4j:
|
||||
# 是否开启Knife4j增强模式
|
||||
enable: true
|
||||
# 是否开启生产环境保护策略
|
||||
production: @knife4j.production@
|
||||
# 前端Ui的个性化配置属性
|
||||
setting:
|
||||
# 默认语言
|
||||
language: zh-CN
|
||||
# 是否显示Footer
|
||||
enableFooter: false
|
||||
# 是否开启动态参数调试功能
|
||||
enableDynamicParameter: true
|
||||
# 是否在每个Debug调试栏后显示刷新变量按钮
|
||||
enableReloadCacheParameter: true
|
||||
|
||||
# 防止XSS攻击
|
||||
xss:
|
||||
# 过滤开关
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.ruoyi.framework.config;
|
||||
|
||||
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
||||
import com.github.xiaoymin.knife4j.spring.extension.OpenApiExtensionResolver;
|
||||
import com.ruoyi.common.properties.TokenProperties;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
@ -35,6 +36,9 @@ public class SwaggerConfig {
|
||||
@Autowired
|
||||
private TokenProperties tokenProperties;
|
||||
|
||||
@Autowired
|
||||
private OpenApiExtensionResolver openApiExtensionResolver;
|
||||
|
||||
/**
|
||||
* 创建API
|
||||
*/
|
||||
@ -59,6 +63,7 @@ public class SwaggerConfig {
|
||||
// 设置安全模式,swagger可以设置访问token
|
||||
.securitySchemes(securitySchemes())
|
||||
.securityContexts(securityContexts())
|
||||
.extensions(openApiExtensionResolver.buildExtensions(group.getName()))
|
||||
.pathMapping(swaggerProperties.getPathMapping());
|
||||
String beanName = StringUtils.substringAfterLast(basePackage, ".") + "Docket";
|
||||
SpringUtils.registerBean(beanName, docket);
|
||||
|
Loading…
x
Reference in New Issue
Block a user