提交 8730e89e 编写于 作者: F fengyw

网关增加聚合接口文档,更方便接口文档的查看和对接

上级 6ab7b639
......@@ -7,6 +7,7 @@
4. 切换网关组件为Spring CLoud Gateway
5. 增加nacos_cofig.zip配置,nacos可以一键导入
6. 将file_storage的表file_type修改为file_classify
7. 网关增加聚合接口文档,更方便接口文档的查看和对接
---
###### v9.0.0-RELEASE
......
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)));
}
}
package com.roncoo.education.app.gateway.swagger;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.config.GatewayProperties;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Component
@Primary
@AllArgsConstructor
public class SwaggerResourceConfig implements SwaggerResourcesProvider {
private final RouteLocator routeLocator;
private final GatewayProperties gatewayProperties;
@Override
public List<SwaggerResource> get() {
List<SwaggerResource> resources = new ArrayList<>();
List<String> routes = new ArrayList<>();
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")));
});
return resources;
}
private SwaggerResource swaggerResource(String name, String location) {
SwaggerResource swaggerResource = new SwaggerResource();
swaggerResource.setName(name);
swaggerResource.setLocation("/" + name + location);
swaggerResource.setSwaggerVersion("2.0");
return swaggerResource;
}
}
# 视频存放路径
# ??????
period_video_path=/home/roncoo/file/video/
pic_path=/home/roncoo/file/pic/
#本地上传文档路径
#????????
doc_storage_path=C:/RonCoo/doc/
#本地上传路径路径
#????????
pic_storage_path=C:/RonCoo/pic/
#测试课程id
#????id
test_course=1085453180200448002
# 保利威视
# ????
polyv_uploadVideo=http://v.polyv.net/uc/services/rest?method=uploadfile
polyv_deleteVideo=http://api.polyv.net/v2/video/{userid}/del-video
polyv_question=http://v.polyv.net/uc/services/rest
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册