|
@@ -1,7 +1,12 @@
|
1
|
1
|
package com.example.demo.controller;
|
2
|
2
|
|
|
3
|
+import io.swagger.annotations.Api;
|
|
4
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
5
|
+import io.swagger.annotations.ApiOperation;
|
3
|
6
|
import org.springframework.beans.factory.annotation.Value;
|
4
|
7
|
import org.springframework.stereotype.Controller;
|
|
8
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
9
|
+import org.springframework.web.bind.annotation.PathVariable;
|
5
|
10
|
import org.springframework.web.bind.annotation.RequestMapping;
|
6
|
11
|
import org.springframework.web.bind.annotation.ResponseBody;
|
7
|
12
|
|
|
@@ -11,15 +16,22 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
11
|
16
|
*/
|
12
|
17
|
@Controller
|
13
|
18
|
@RequestMapping("/")
|
|
19
|
+@Api("测试controller的API")
|
14
|
20
|
public class TestController {
|
15
|
21
|
|
16
|
|
- @Value("${abc}")
|
17
|
|
- private String abc;
|
18
|
|
-
|
19
|
|
- @RequestMapping("/test")
|
|
22
|
+ @ApiOperation(value = "测试无参", notes = "无参")
|
|
23
|
+ @GetMapping("/test")
|
20
|
24
|
@ResponseBody
|
21
|
25
|
public String test(){
|
22
|
|
- System.out.println(abc);
|
23
|
|
- return "ok====" + abc;
|
|
26
|
+ return "ok====";
|
24
|
27
|
}
|
|
28
|
+
|
|
29
|
+ @ApiOperation(value = "测试restful接口", notes = "测试接口")
|
|
30
|
+ @ApiImplicitParam(name = "id", value = "测试ID", paramType = "path", required = true, dataType = "String")
|
|
31
|
+ @GetMapping("/test/{id}")
|
|
32
|
+ @ResponseBody
|
|
33
|
+ public String testSwagger(@PathVariable String id){
|
|
34
|
+ return id;
|
|
35
|
+ }
|
|
36
|
+
|
25
|
37
|
}
|