Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-manage
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
finance-oa
finance-manage
Commits
5434ceb1
Commit
5434ceb1
authored
May 17, 2020
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swagger请求前缀加入配置。
parent
922f61e0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
ruoyi/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java
...c/main/java/com/ruoyi/framework/config/SwaggerConfig.java
+13
-9
ruoyi/src/main/resources/application.yml
ruoyi/src/main/resources/application.yml
+4
-1
No files found.
ruoyi/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java
View file @
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
);
}
}
/**
/**
...
...
ruoyi/src/main/resources/application.yml
View file @
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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment