Skip to content

Commit ffa5816

Browse files
committed
feature: support swagger
1 parent afc3e32 commit ffa5816

File tree

11 files changed

+59
-0
lines changed

11 files changed

+59
-0
lines changed

console/pom.xml

+13
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,19 @@
142142
<groupId>javax.servlet</groupId>
143143
<artifactId>javax.servlet-api</artifactId>
144144
</dependency>
145+
146+
<!-- swagger -->
147+
<dependency>
148+
<groupId>io.springfox</groupId>
149+
<artifactId>springfox-swagger2</artifactId>
150+
<version>2.7.0</version>
151+
</dependency>
152+
<dependency>
153+
<groupId>io.springfox</groupId>
154+
<artifactId>springfox-swagger-ui</artifactId>
155+
<version>2.7.0</version>
156+
</dependency>
157+
145158
<!--<dependency>
146159
<groupId>io.jsonwebtoken</groupId>
147160
<artifactId>jjwt</artifactId>

console/src/main/java/org/apache/seata/console/controller/AuthController.java

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.seata.console.controller;
1818

19+
import io.swagger.annotations.Api;
20+
import io.swagger.annotations.ApiOperation;
1921
import org.apache.seata.common.result.Code;
2022
import org.apache.seata.common.result.SingleResult;
2123
import org.apache.seata.console.config.ConsoleSecurityConfig;
@@ -39,6 +41,7 @@
3941
*
4042
*/
4143
@RestController
44+
@Api(tags = "Console authentication APIs")
4245
@RequestMapping("/api/v1/auth")
4346
public class AuthController {
4447
@Autowired
@@ -57,6 +60,7 @@ public class AuthController {
5760
* @return HTTP code equal to 200 indicates that Seata is in right states. HTTP code equal to 500 indicates that
5861
* Seata is in broken states.
5962
*/
63+
@ApiOperation("login and get access token and refresh token")
6064
@PostMapping("/login")
6165
public SingleResult<String> login(HttpServletResponse response, @RequestBody User user) {
6266
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(

console/src/main/java/org/apache/seata/console/controller/OverviewController.java

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.seata.console.controller;
1818

19+
import io.swagger.annotations.Api;
20+
import io.swagger.annotations.ApiOperation;
1921
import org.apache.seata.common.result.Code;
2022
import org.apache.seata.common.result.SingleResult;
2123
import org.springframework.web.bind.annotation.GetMapping;
@@ -31,6 +33,7 @@
3133
*
3234
*/
3335
@RestController
36+
@Api(tags = "Overview APIs")
3437
@RequestMapping("/api/v1/overview")
3538
public class OverviewController {
3639

@@ -39,6 +42,7 @@ public class OverviewController {
3942
*
4043
* @return the data
4144
*/
45+
@ApiOperation("get data")
4246
@GetMapping(value = "/getData")
4347
public SingleResult<List> getData() {
4448
List<Map<String, Object>> result = new ArrayList<>();

server/src/main/java/org/apache/seata/server/auth/config/Swagger2Config.java

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<<<<<<< HEAD
12
/*
23
* Licensed to the Apache Software Foundation (ASF) under one or more
34
* contributor license agreements. See the NOTICE file distributed with
@@ -17,6 +18,12 @@
1718
package org.apache.seata.server.auth.config;
1819

1920
import com.google.common.base.Predicates;
21+
=======
22+
package org.apache.seata.server.auth.config;
23+
24+
import com.google.common.base.Predicates;
25+
import org.apache.seata.console.config.ConsoleSecurityConfig;
26+
>>>>>>> dcbba42f0 (feature: support swagger)
2027
import org.springframework.context.annotation.Bean;
2128
import org.springframework.context.annotation.Configuration;
2229
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

server/src/main/java/org/apache/seata/server/auth/controller/ClusterAuthController.java

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.seata.server.auth.controller;
1818

19+
import io.swagger.annotations.Api;
20+
import io.swagger.annotations.ApiOperation;
1921
import org.apache.seata.common.result.Code;
2022
import org.apache.seata.common.result.SingleResult;
2123
import org.apache.seata.server.auth.config.ClusterSecurityConfig;
@@ -36,11 +38,14 @@
3638
import javax.servlet.http.HttpServletResponse;
3739

3840
@RestController
41+
@Api(tags = "Cluster authentication APIs")
3942
@RequestMapping("/metadata/v1/auth")
4043
public class ClusterAuthController {
44+
4145
@Autowired
4246
@Qualifier("clusterJwtTokenUtils")
4347
private ClusterJwtTokenUtils jwtTokenUtils;
48+
4449
@Autowired
4550
@Qualifier("clusterAuthenticationManager")
4651
private AuthenticationManager authenticationManager;
@@ -53,6 +58,7 @@ public class ClusterAuthController {
5358
* @return HTTP code equal to 200 indicates that Seata is in right states. HTTP code equal to 500 indicates that
5459
* Seata is in broken states.
5560
*/
61+
@ApiOperation("login to get access token and refresh token")
5662
@PostMapping("/login")
5763
public SingleResult<String> login(HttpServletResponse response, @RequestBody User user) {
5864
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(

server/src/main/java/org/apache/seata/server/console/controller/BranchSessionController.java

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.seata.server.console.controller;
1818

19+
import io.swagger.annotations.Api;
1920
import org.apache.seata.server.console.service.BranchSessionService;
2021
import org.springframework.web.bind.annotation.RequestMapping;
2122
import org.springframework.web.bind.annotation.RestController;
@@ -26,6 +27,7 @@
2627
* Branch Session Controller
2728
*/
2829
@RestController
30+
@Api(tags = "Branch session APIs")
2931
@RequestMapping("/api/v1/console/branchSession")
3032
public class BranchSessionController {
3133

server/src/main/java/org/apache/seata/server/console/controller/GlobalLockController.java

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import javax.annotation.Resource;
2020

21+
import io.swagger.annotations.Api;
22+
import io.swagger.annotations.ApiOperation;
2123
import org.apache.seata.common.result.PageResult;
2224
import org.apache.seata.server.console.param.GlobalLockParam;
2325
import org.apache.seata.server.console.vo.GlobalLockVO;
@@ -32,6 +34,7 @@
3234
* Global Lock Controller
3335
*/
3436
@RestController
37+
@Api(tags = "Global lock APIs")
3538
@RequestMapping("/api/v1/console/globalLock")
3639
public class GlobalLockController {
3740

@@ -43,6 +46,7 @@ public class GlobalLockController {
4346
* @param param the param
4447
* @return the list of GlobalLockVO
4548
*/
49+
@ApiOperation("query global lock")
4650
@GetMapping("query")
4751
public PageResult<GlobalLockVO> query(@ModelAttribute GlobalLockParam param) {
4852
return globalLockService.query(param);

server/src/main/java/org/apache/seata/server/console/controller/GlobalSessionController.java

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import javax.annotation.Resource;
2020

21+
import io.swagger.annotations.Api;
22+
import io.swagger.annotations.ApiOperation;
2123
import org.apache.seata.server.console.param.GlobalSessionParam;
2224
import org.apache.seata.common.result.PageResult;
2325
import org.apache.seata.server.console.vo.GlobalSessionVO;
@@ -31,6 +33,7 @@
3133
* Global Session Controller
3234
*/
3335
@RestController
36+
@Api(tags = "Global session APIs")
3437
@RequestMapping("/api/v1/console/globalSession")
3538
public class GlobalSessionController {
3639

@@ -42,6 +45,7 @@ public class GlobalSessionController {
4245
* @param param param for query globalSession
4346
* @return the list of GlobalSessionVO
4447
*/
48+
@ApiOperation("query global session")
4549
@GetMapping("query")
4650
public PageResult<GlobalSessionVO> query(@ModelAttribute GlobalSessionParam param) {
4751
return globalSessionService.query(param);

server/src/main/java/org/apache/seata/server/controller/ClusterController.java

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import com.alipay.sofa.jraft.RouteTable;
2929
import com.alipay.sofa.jraft.conf.Configuration;
3030
import com.alipay.sofa.jraft.entity.PeerId;
31+
import io.swagger.annotations.Api;
32+
import io.swagger.annotations.ApiOperation;
3133
import org.apache.seata.common.ConfigurationKeys;
3234
import org.apache.seata.common.metadata.MetadataResponse;
3335
import org.apache.seata.common.metadata.Node;
@@ -55,6 +57,7 @@
5557
/**
5658
*/
5759
@RestController
60+
@Api(tags = "Raft cluster APIs")
5861
@RequestMapping("/metadata/v1")
5962
public class ClusterController {
6063

@@ -73,6 +76,7 @@ private void init() {
7376
this.serverProperties = applicationContext.getBean(ServerProperties.class);
7477
}
7578

79+
@ApiOperation("changeCluster")
7680
@PostMapping("/changeCluster")
7781
public Result<?> changeCluster(@RequestParam String raftClusterStr) {
7882
Result<?> result = new Result<>();
@@ -89,6 +93,7 @@ public Result<?> changeCluster(@RequestParam String raftClusterStr) {
8993
return result;
9094
}
9195

96+
@ApiOperation("cluster")
9297
@GetMapping("/cluster")
9398
public MetadataResponse cluster(String group) {
9499
MetadataResponse metadataResponse = new MetadataResponse();
@@ -122,6 +127,7 @@ public MetadataResponse cluster(String group) {
122127
return metadataResponse;
123128
}
124129

130+
@ApiOperation("watch follower")
125131
@PostMapping("/watch")
126132
public void watch(HttpServletRequest request, @RequestParam Map<String, Object> groupTerms,
127133
@RequestParam(defaultValue = "28000") int timeout) {

server/src/main/java/org/apache/seata/server/controller/HealthController.java

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.seata.server.controller;
1818

19+
import io.swagger.annotations.Api;
20+
import io.swagger.annotations.ApiOperation;
1921
import org.apache.seata.server.ServerRunner;
2022
import org.springframework.beans.factory.annotation.Autowired;
2123
import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,6 +26,7 @@
2426
/**
2527
*/
2628
@RestController
29+
@Api(tags = "Health APIs")
2730
public class HealthController {
2831

2932
private static final String OK = "ok";
@@ -34,6 +37,7 @@ public class HealthController {
3437

3538

3639
@RequestMapping("/health")
40+
@ApiOperation("health")
3741
String healthCheck() {
3842
return serverRunner.started() ? OK : NOT_OK;
3943
}

server/src/main/java/org/apache/seata/server/controller/VGroupMappingController.java

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.seata.server.controller;
1818

19+
import io.swagger.annotations.Api;
20+
import io.swagger.annotations.ApiOperation;
1921
import org.apache.seata.common.metadata.namingserver.Instance;
2022
import org.apache.seata.common.result.Result;
2123
import org.apache.seata.common.util.StringUtils;
@@ -37,6 +39,7 @@
3739
import static org.apache.seata.common.ConfigurationKeys.NAMING_SERVER;
3840

3941
@RestController
42+
@Api(tags = "VGroup mapping APIs")
4043
@RequestMapping("/vgroup/v1")
4144
public class VGroupMappingController {
4245

@@ -59,6 +62,7 @@ private void init() {
5962
* @param vGroup
6063
* @return
6164
*/
65+
@ApiOperation("add VGroup")
6266
@GetMapping("/addVGroup")
6367
public Result<?> addVGroup(@RequestParam String vGroup, @RequestParam String unit) {
6468
Result<?> result = new Result<>();
@@ -82,6 +86,7 @@ public Result<?> addVGroup(@RequestParam String vGroup, @RequestParam String uni
8286
* @param vGroup
8387
* @return
8488
*/
89+
@ApiOperation("remove VGroup")
8590
@GetMapping("/removeVGroup")
8691
public Result<?> removeVGroup(@RequestParam String vGroup) {
8792
Result<?> result = new Result<>();

0 commit comments

Comments
 (0)