Commit c2b58e88 authored by wutu's avatar wutu

新增Swagger文档

parent 5fc70d0b
...@@ -63,6 +63,15 @@ ...@@ -63,6 +63,15 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!--自动生成文档-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package top.ninwoo.cloudcenter.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.pathMapping("/")
.select()
.apis(RequestHandlerSelectors.basePackage("top.ninwoo.cloudcenter.controller"))
.paths(PathSelectors.any())
.build().apiInfo(new ApiInfoBuilder().title("CNF云平台Swagger文档")
.description("由Swagger自动生成,仅限测试环境使用")
.version("1.0")
.contact(new Contact("joliu", "opengn.org", "ljo0412@live.com"))
.license("The Apache License")
.licenseUrl("http://git.opensource5g.org/xidiancos/cnf/-/blob/master/LICENSE")
.build());
}
}
package top.ninwoo.cloudcenter.controller; package top.ninwoo.cloudcenter.controller;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import top.ninwoo.cloudcenter.service.CloudService; import top.ninwoo.cloudcenter.service.CloudService;
import top.ninwoo.common.entity.NetworkTopology; import top.ninwoo.common.entity.NetworkTopology;
...@@ -9,19 +10,24 @@ import javax.annotation.Resource; ...@@ -9,19 +10,24 @@ import javax.annotation.Resource;
import java.util.List; import java.util.List;
@RestController @RestController
@Api(tags = "容器集群管理相关接口")
@RequestMapping("/cluster") @RequestMapping("/cluster")
public class ClusterController { public class ClusterController {
@Resource @Resource
CloudService cloudService; CloudService cloudService;
@RequestMapping(value = "/sendClusterConfigToEdgeNode", method = RequestMethod.POST) @ApiOperation("下发集群配置")
@ApiImplicitParam(name = "clusterConfigs", value = "集群配置类", defaultValue = "", dataType = "List" ,required = true)
@PostMapping(value = "/sendClusterConfigToEdgeNode")
public List<SeparatedClusterConfig> sendClusterConfigToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) { public List<SeparatedClusterConfig> sendClusterConfigToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) {
// return cloudService.sendClusterConfigToEdgeNode(clusterConfigs); // return cloudService.sendClusterConfigToEdgeNode(clusterConfigs);
return cloudService.sendClusterConfigToEdgeNodeByThreads(clusterConfigs); return cloudService.sendClusterConfigToEdgeNodeByThreads(clusterConfigs);
} }
@RequestMapping(value = "/removeClusterFromEdgeNode") @ApiOperation("删除集群")
@ApiImplicitParam(name = "clusterId", value = "容器集群ID", defaultValue = "11111", required = true)
@GetMapping(value = "/removeClusterFromEdgeNode")
public String removeClusterFromEdgeNode(Long clusterId) { public String removeClusterFromEdgeNode(Long clusterId) {
boolean res = cloudService.deleteClusterFromEdgeNode(clusterId); boolean res = cloudService.deleteClusterFromEdgeNode(clusterId);
if(res) { if(res) {
...@@ -30,22 +36,29 @@ public class ClusterController { ...@@ -30,22 +36,29 @@ public class ClusterController {
return "fail"; return "fail";
} }
@RequestMapping(value = "/getEdgeNodeIds") @ApiOperation("获取边缘节点")
@GetMapping(value = "/getEdgeNodeIds")
public List<String> getEdgeNodeIds() { public List<String> getEdgeNodeIds() {
return cloudService.getEdgeNodeIds(); return cloudService.getEdgeNodeIds();
} }
@RequestMapping(value = "/adjustCluster", method = RequestMethod.POST) @ApiOperation("调整容器集群")
@ApiImplicitParam(name = "clusterConfigs", value = "集群配置类", defaultValue = "", required = true)
@PostMapping(value = "/adjustCluster")
public Boolean adjustClusterToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) { public Boolean adjustClusterToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) {
return cloudService.adjustCluster(clusterConfigs); return cloudService.adjustCluster(clusterConfigs);
} }
@RequestMapping(value = "/sendLogicTopo", method = RequestMethod.POST) @ApiOperation("下发容器逻辑拓扑")
@ApiImplicitParam(name = "clusterConfigs", value = "集群配置类", defaultValue = "", required = true)
@PostMapping(value = "/sendLogicTopo")
public Boolean sendLogicTopoToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) { public Boolean sendLogicTopoToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) {
return cloudService.sendLogicTopo(clusterConfigs); return cloudService.sendLogicTopo(clusterConfigs);
} }
@RequestMapping(value = "/adjustLogicTopo", method = RequestMethod.POST) @ApiOperation("调整容器逻辑拓扑")
@ApiImplicitParam(name = "clusterConfigs", value = "集群配置类", defaultValue = "", required = true)
@PostMapping(value = "/adjustLogicTopo")
public Boolean adjustLogicTopoToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) { public Boolean adjustLogicTopoToEdgeNode(@RequestBody List<SeparatedClusterConfig> clusterConfigs) {
return cloudService.adjustLogicTopo(clusterConfigs); return cloudService.adjustLogicTopo(clusterConfigs);
} }
......
...@@ -2,10 +2,10 @@ server: ...@@ -2,10 +2,10 @@ server:
port: 9091 port: 9091
zookeeper: zookeeper:
url: 192.168.31.156:2181 url: 127.0.0.1:2181
bs: bs:
cloudcenter: cloudcenter:
name: my-bs-cloud-center name: my-bs-cloud-center
ipservice: ipservice:
url: 192.168.31.156:23333 url: 127.0.0.1:23333
\ No newline at end of file \ No newline at end of file
...@@ -19,5 +19,9 @@ ...@@ -19,5 +19,9 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
package top.ninwoo.common.entity; package top.ninwoo.common.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@Data @Data
public class SeparatedClusterConfig { public class SeparatedClusterConfig {
@ApiModelProperty
private ClusterConfig clusterConfig; private ClusterConfig clusterConfig;
@ApiModelProperty
private String edgeNodeId; private String edgeNodeId;
} }
...@@ -26,9 +26,9 @@ bs: ...@@ -26,9 +26,9 @@ bs:
name: random name: random
ip-prefix: 192.168.31 ip-prefix: 192.168.31
ipservice: ipservice:
ip: 192.168.31.238:23333 ip: 192.168.31.198:23333
sdn-controller: sdn-controller:
host: 127.0.0.1 host: 127.0.0.1
port: 6653 port: 6653
zookeeper: zookeeper:
url: 192.168.31.238:2181 url: 192.168.31.198:2181
...@@ -145,6 +145,16 @@ ...@@ -145,6 +145,16 @@
<artifactId>influxdb-java</artifactId> <artifactId>influxdb-java</artifactId>
<version>2.9</version> <version>2.9</version>
</dependency> </dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment