Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cocktail-party-server
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
cocktail-party
cocktail-party-server
Commits
5434ceb1
提交
5434ceb1
authored
5月 17, 2020
作者:
RuoYi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
swagger请求前缀加入配置。
上级
922f61e0
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
10 行删除
+17
-10
SwaggerConfig.java
...c/main/java/com/ruoyi/framework/config/SwaggerConfig.java
+13
-9
application.yml
ruoyi/src/main/resources/application.yml
+4
-1
没有找到文件。
ruoyi/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java
浏览文件 @
5434ceb1
...
@@ -33,9 +33,13 @@ public class SwaggerConfig
...
@@ -33,9 +33,13 @@ public class SwaggerConfig
@Autowired
@Autowired
private
RuoYiConfig
ruoyiConfig
;
private
RuoYiConfig
ruoyiConfig
;
/** Swagger开关配置 */
/** 是否开启swagger */
@Value
(
"${swagger.enable}"
)
@Value
(
"${swagger.enabled}"
)
private
boolean
swaggerEnable
;
private
boolean
enabled
;
/** 设置请求的统一前缀 */
@Value
(
"${swagger.pathMapping}"
)
private
String
pathMapping
;
/**
/**
* 创建API
* 创建API
...
@@ -45,8 +49,7 @@ public class SwaggerConfig
...
@@ -45,8 +49,7 @@ public class SwaggerConfig
{
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
// 是否启用Swagger
// 是否启用Swagger
.
enable
(
swaggerEnable
)
.
enable
(
enabled
)
.
pathMapping
(
"/dev-api"
)
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
// 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
.
apiInfo
(
apiInfo
())
.
apiInfo
(
apiInfo
())
// 设置哪些接口暴露给Swagger展示
// 设置哪些接口暴露给Swagger展示
...
@@ -54,13 +57,14 @@ public class SwaggerConfig
...
@@ -54,13 +57,14 @@ public class SwaggerConfig
// 扫描所有有注解的api,用这种方式更灵活
// 扫描所有有注解的api,用这种方式更灵活
.
apis
(
RequestHandlerSelectors
.
withMethodAnnotation
(
ApiOperation
.
class
))
.
apis
(
RequestHandlerSelectors
.
withMethodAnnotation
(
ApiOperation
.
class
))
// 扫描指定包中的swagger注解
// 扫描指定包中的swagger注解
//.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
//
.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
// 扫描所有 .apis(RequestHandlerSelectors.any())
// 扫描所有 .apis(RequestHandlerSelectors.any())
.
paths
(
PathSelectors
.
any
())
.
paths
(
PathSelectors
.
any
())
.
build
()
.
build
()
/* 设置安全模式,swagger可以设置访问token */
/* 设置安全模式,swagger可以设置访问token */
.
securitySchemes
(
securitySchemes
())
.
securitySchemes
(
securitySchemes
())
.
securityContexts
(
securityContexts
());
.
securityContexts
(
securityContexts
())
.
pathMapping
(
pathMapping
);
}
}
/**
/**
...
@@ -72,7 +76,7 @@ public class SwaggerConfig
...
@@ -72,7 +76,7 @@ public class SwaggerConfig
apiKeyList
.
add
(
new
ApiKey
(
"Authorization"
,
"Authorization"
,
"header"
));
apiKeyList
.
add
(
new
ApiKey
(
"Authorization"
,
"Authorization"
,
"header"
));
return
apiKeyList
;
return
apiKeyList
;
}
}
/**
/**
* 安全上下文
* 安全上下文
*/
*/
...
@@ -86,7 +90,7 @@ public class SwaggerConfig
...
@@ -86,7 +90,7 @@ public class SwaggerConfig
.
build
());
.
build
());
return
securityContexts
;
return
securityContexts
;
}
}
/**
/**
* 默认的安全上引用
* 默认的安全上引用
*/
*/
...
...
ruoyi/src/main/resources/application.yml
浏览文件 @
5434ceb1
...
@@ -102,7 +102,10 @@ pagehelper:
...
@@ -102,7 +102,10 @@ pagehelper:
# Swagger配置
# Swagger配置
swagger
:
swagger
:
enable
:
true
# 是否开启swagger
enabled
:
true
# 请求前缀
pathMapping
:
/dev-api
# 防止XSS攻击
# 防止XSS攻击
xss
:
xss
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论