Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
roncoo
roncoo-education
提交
43052a64
R
roncoo-education
项目概览
roncoo
/
roncoo-education
11 个月 前同步成功
通知
146
Star
5
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roncoo-education
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
43052a64
编写于
7月 16, 2023
作者:
F
fengyw
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
升级大版本,并进行架构调整
上级
175b5bb6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
57 deletion
+10
-57
roncoo-education-app/roncoo-education-app-gateway/src/main/java/com/roncoo/education/app/gateway/swagger/SwaggerHandler.java
.../roncoo/education/app/gateway/swagger/SwaggerHandler.java
+0
-50
roncoo-education-app/roncoo-education-app-gateway/src/main/java/com/roncoo/education/app/gateway/swagger/SwaggerResourceConfig.java
.../education/app/gateway/swagger/SwaggerResourceConfig.java
+10
-7
未找到文件。
roncoo-education-app/roncoo-education-app-gateway/src/main/java/com/roncoo/education/app/gateway/swagger/SwaggerHandler.java
已删除
100644 → 0
浏览文件 @
175b5bb6
package
com.roncoo.education.app.gateway.swagger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
reactor.core.publisher.Mono
;
import
springfox.documentation.swagger.web.*
;
import
java.util.Optional
;
@RestController
public
class
SwaggerHandler
{
@Autowired
(
required
=
false
)
private
SecurityConfiguration
securityConfiguration
;
@Autowired
(
required
=
false
)
private
UiConfiguration
uiConfiguration
;
private
final
SwaggerResourcesProvider
swaggerResources
;
@Autowired
public
SwaggerHandler
(
SwaggerResourcesProvider
swaggerResources
)
{
this
.
swaggerResources
=
swaggerResources
;
}
@GetMapping
(
"/swagger-resources/configuration/security"
)
public
Mono
<
ResponseEntity
<
SecurityConfiguration
>>
securityConfiguration
()
{
return
Mono
.
just
(
new
ResponseEntity
<>(
Optional
.
ofNullable
(
securityConfiguration
)
.
orElse
(
SecurityConfigurationBuilder
.
builder
().
build
()),
HttpStatus
.
OK
));
}
@GetMapping
(
"/swagger-resources/configuration/ui"
)
public
Mono
<
ResponseEntity
<
UiConfiguration
>>
uiConfiguration
()
{
return
Mono
.
just
(
new
ResponseEntity
<>(
Optional
.
ofNullable
(
uiConfiguration
).
orElse
(
UiConfigurationBuilder
.
builder
().
build
()),
HttpStatus
.
OK
));
}
@GetMapping
(
"/swagger-resources"
)
public
Mono
<
ResponseEntity
>
swaggerResources
()
{
return
Mono
.
just
((
new
ResponseEntity
<>(
swaggerResources
.
get
(),
HttpStatus
.
OK
)));
}
}
roncoo-education-app/roncoo-education-app-gateway/src/main/java/com/roncoo/education/app/gateway/swagger/SwaggerResourceConfig.java
浏览文件 @
43052a64
...
...
@@ -12,12 +12,18 @@ import springfox.documentation.swagger.web.SwaggerResourcesProvider;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author fengyw
*/
@Slf4j
@Component
@Primary
@AllArgsConstructor
public
class
SwaggerResourceConfig
implements
SwaggerResourcesProvider
{
private
static
final
String
LOCATION
=
"/v3/api-docs"
;
private
static
final
String
VERSION
=
"3.0"
;
private
final
RouteLocator
routeLocator
;
private
final
GatewayProperties
gatewayProperties
;
...
...
@@ -28,12 +34,9 @@ public class SwaggerResourceConfig implements SwaggerResourcesProvider {
routeLocator
.
getRoutes
().
subscribe
(
route
->
routes
.
add
(
route
.
getId
()));
gatewayProperties
.
getRoutes
().
stream
()
.
filter
(
routeDefinition
->
routes
.
contains
(
routeDefinition
.
getId
()))
.
forEach
(
route
->
{
route
.
getPredicates
().
forEach
(
predicateDefinition
->
resources
.
add
(
swaggerResource
(
route
.
getId
(),
"/v2/api-docs"
)));
});
.
forEach
(
route
->
route
.
getPredicates
().
forEach
(
predicateDefinition
->
resources
.
add
(
swaggerResource
(
route
.
getId
(),
LOCATION
))
));
return
resources
;
}
...
...
@@ -41,7 +44,7 @@ public class SwaggerResourceConfig implements SwaggerResourcesProvider {
SwaggerResource
swaggerResource
=
new
SwaggerResource
();
swaggerResource
.
setName
(
name
);
swaggerResource
.
setLocation
(
"/"
+
name
+
location
);
swaggerResource
.
setSwaggerVersion
(
"2.0"
);
swaggerResource
.
setSwaggerVersion
(
VERSION
);
return
swaggerResource
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录