Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-api-boot
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-api-boot
Commits
5f2d42ef
提交
5f2d42ef
authored
6月 22, 2022
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 新增 SwaggerDoc 分组配置
上级
182a1b2b
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
41 行增加
和
10 行删除
+41
-10
package-info.java
...src/main/java/com/yiring/app/web/common/package-info.java
+4
-2
ExampleController.java
...in/java/com/yiring/app/web/example/ExampleController.java
+6
-1
package-info.java
app/src/main/java/com/yiring/app/web/package-info.java
+4
-2
SwaggerConfig.java
...rc/main/java/com/yiring/common/swagger/SwaggerConfig.java
+27
-5
没有找到文件。
basic-auth/src/main/java/com/yiring/auth
/package-info.java
→
app/src/main/java/com/yiring/app/web/common
/package-info.java
浏览文件 @
5f2d42ef
/**
/**
* 公共接口
*
* @author Jim
* @author Jim
* @version 0.1
* @version 0.1
* 2022/
3/23 16:18
* 2022/
6/22 11:30
*/
*/
package
com
.
yiring
.
a
uth
;
package
com
.
yiring
.
a
pp
.
web
.
common
;
app/src/main/java/com/yiring/app/web/ExampleController.java
→
app/src/main/java/com/yiring/app/web/
example/
ExampleController.java
浏览文件 @
5f2d42ef
/* (C) 2021 YiRing, Inc. */
/* (C) 2021 YiRing, Inc. */
package
com
.
yiring
.
app
.
web
;
package
com
.
yiring
.
app
.
web
.
example
;
import
cn.hutool.extra.spring.SpringUtil
;
import
cn.hutool.extra.spring.SpringUtil
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
...
@@ -26,6 +26,11 @@ import org.springframework.web.bind.annotation.GetMapping;
...
@@ -26,6 +26,11 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 示例接口
* @author Jim
*/
@Slf4j
@Slf4j
@Validated
@Validated
@SuppressWarnings
({
"deprecation"
})
@SuppressWarnings
({
"deprecation"
})
...
...
basic-auth/src/main/java/com/yiring/auth
/web/package-info.java
→
app/src/main/java/com/yiring/app
/web/package-info.java
浏览文件 @
5f2d42ef
/**
/**
* Controller
*
* @author Jim
* @author Jim
* @version 0.1
* @version 0.1
* 2022/
3/24 16:37
* 2022/
6/22 11:29
*/
*/
package
com
.
yiring
.
a
uth
.
web
;
package
com
.
yiring
.
a
pp
.
web
;
basic-common/doc/src/main/java/com/yiring/common/swagger/SwaggerConfig.java
浏览文件 @
5f2d42ef
...
@@ -20,6 +20,7 @@ import org.springframework.context.annotation.Import;
...
@@ -20,6 +20,7 @@ import org.springframework.context.annotation.Import;
import
org.springframework.context.annotation.Profile
;
import
org.springframework.context.annotation.Profile
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration
;
import
springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration
;
import
springfox.documentation.RequestHandler
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
...
@@ -58,13 +59,34 @@ public class SwaggerConfig implements CommandLineRunner {
...
@@ -58,13 +59,34 @@ public class SwaggerConfig implements CommandLineRunner {
@Resource
@Resource
OpenApiExtensionResolver
openApiExtensionResolver
;
OpenApiExtensionResolver
openApiExtensionResolver
;
@Bean
@Bean
(
name
=
"api.default"
)
public
Docket
api
()
{
public
Docket
api
()
{
return
api
(
PathSelectors
.
any
());
return
api
(
"@default"
,
List
.
of
(
""
),
PathSelectors
.
any
());
}
}
private
Docket
api
(
Predicate
<
String
>
paths
)
{
@Bean
(
name
=
"api.auth"
)
String
group
=
"default"
;
public
Docket
auth
()
{
return
api
(
"Auth"
,
List
.
of
(
"com.yiring.auth.web.auth"
),
PathSelectors
.
any
());
}
@Bean
(
name
=
"api.common"
)
public
Docket
common
()
{
return
api
(
"公共"
,
List
.
of
(
"com.yiring.common.web"
,
"com.yiring.app.web.common"
),
PathSelectors
.
any
());
}
@Bean
(
name
=
"api.example"
)
public
Docket
example
()
{
return
api
(
"示例"
,
List
.
of
(
"com.yiring.app.web.example"
),
PathSelectors
.
any
());
}
private
Docket
api
(
String
group
,
List
<
String
>
basePackages
,
Predicate
<
String
>
paths
)
{
// 扫描多个包
Predicate
<
RequestHandler
>
predicate
=
basePackages
.
stream
()
.
map
(
RequestHandlerSelectors:
:
basePackage
)
.
reduce
(
Predicate:
:
or
)
.
orElse
(
RequestHandlerSelectors
.
none
());
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
groupName
(
group
)
.
groupName
(
group
)
.
apiInfo
(
apiInfo
())
.
apiInfo
(
apiInfo
())
...
@@ -74,7 +96,7 @@ public class SwaggerConfig implements CommandLineRunner {
...
@@ -74,7 +96,7 @@ public class SwaggerConfig implements CommandLineRunner {
.
globalResponseMessage
(
RequestMethod
.
DELETE
,
buildGlobalResponseMessage
())
.
globalResponseMessage
(
RequestMethod
.
DELETE
,
buildGlobalResponseMessage
())
.
globalResponseMessage
(
RequestMethod
.
PUT
,
buildGlobalResponseMessage
())
.
globalResponseMessage
(
RequestMethod
.
PUT
,
buildGlobalResponseMessage
())
.
select
()
.
select
()
.
apis
(
RequestHandlerSelectors
.
withClassAnnotation
(
Api
.
class
))
.
apis
(
RequestHandlerSelectors
.
withClassAnnotation
(
Api
.
class
)
.
and
(
predicate
)
)
.
paths
(
paths
)
.
paths
(
paths
)
.
build
()
.
build
()
.
extensions
(
openApiExtensionResolver
.
buildExtensions
(
group
));
.
extensions
(
openApiExtensionResolver
.
buildExtensions
(
group
));
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论