|
46 | 46 | import org.springframework.web.bind.annotation.RequestBody;
|
47 | 47 | import org.springframework.web.bind.annotation.RequestMapping;
|
48 | 48 | import org.springframework.web.bind.annotation.RequestParam;
|
49 |
| -import org.springframework.web.bind.annotation.ResponseBody; |
50 | 49 | import org.springframework.web.bind.annotation.RestController;
|
51 | 50 | import org.springframework.web.client.RestTemplate;
|
52 | 51 |
|
53 |
| -import com.alibaba.fastjson.JSONArray; |
54 | 52 | import com.alibaba.fastjson.JSONObject;
|
55 | 53 |
|
56 | 54 | import apijson.demo.server.model.BaseModel;
|
@@ -987,6 +985,7 @@ public String delegate(@RequestParam("$_delegate_url") String url, @RequestBody
|
987 | 985 | headers.add(name, request.getHeader(name));
|
988 | 986 | }
|
989 | 987 |
|
| 988 | + @SuppressWarnings("unchecked") |
990 | 989 | List<String> cookie = session == null ? null : (List<String>) session.getAttribute("Cookie");
|
991 | 990 | if (cookie != null && cookie.isEmpty() == false) {
|
992 | 991 | List<String> c = headers.get("Cookie");
|
@@ -1019,9 +1018,71 @@ public String delegate(@RequestParam("$_delegate_url") String url, @RequestBody
|
1019 | 1018 | return entity.getBody();
|
1020 | 1019 | }
|
1021 | 1020 |
|
| 1021 | + |
| 1022 | + /**Swagger 文档 Demo,供 APIAuto 测试导入 Swagger 文档到数据库用 |
| 1023 | + * @return |
| 1024 | + */ |
1022 | 1025 | @GetMapping("v2/api-docs")
|
1023 |
| - public JSONObject swaggerAPIDocs() { |
1024 |
| - return new DemoParser().parseResponse(new JSONRequest("Swagger", new JSONRequest())).getJSONObject("Swagger"); |
| 1026 | + public String swaggerAPIDocs() { |
| 1027 | + return "{\n"+ |
| 1028 | + " \"paths\": {\n"+ |
| 1029 | + " \"/user/list\": {\n"+ |
| 1030 | + " \"get\": {\n"+ |
| 1031 | + " \"summary\": \"用户列表\",\n"+ |
| 1032 | + " \"parameters\": [\n"+ |
| 1033 | + " {\n"+ |
| 1034 | + " \"name\": \"pageSize\",\n"+ |
| 1035 | + " \"description\": \"每页数量\",\n"+ |
| 1036 | + " \"default\": 10\n"+ |
| 1037 | + " },\n"+ |
| 1038 | + " {\n"+ |
| 1039 | + " \"name\": \"page\",\n"+ |
| 1040 | + " \"default\": 1\n"+ |
| 1041 | + " },\n"+ |
| 1042 | + " {\n"+ |
| 1043 | + " \"name\": \"searchKey\",\n"+ |
| 1044 | + " \"description\": \"搜索关键词\",\n"+ |
| 1045 | + " \"default\": \"a\"\n"+ |
| 1046 | + " }\n"+ |
| 1047 | + " ]\n"+ |
| 1048 | + " }\n"+ |
| 1049 | + " },\n"+ |
| 1050 | + " \"/user\": {\n"+ |
| 1051 | + " \"get\": {\n"+ |
| 1052 | + " \"summary\": \"用户详情\",\n"+ |
| 1053 | + " \"parameters\": [\n"+ |
| 1054 | + " {\n"+ |
| 1055 | + " \"name\": \"id\",\n"+ |
| 1056 | + " \"description\": \"主键\",\n"+ |
| 1057 | + " \"default\": 82001\n"+ |
| 1058 | + " }\n"+ |
| 1059 | + " ]\n"+ |
| 1060 | + " }\n"+ |
| 1061 | + " },\n"+ |
| 1062 | + " \"/comment/post\": {\n"+ |
| 1063 | + " \"post\": {\n"+ |
| 1064 | + " \"summary\": \"新增评论\",\n"+ |
| 1065 | + " \"parameters\": [\n"+ |
| 1066 | + " {\n"+ |
| 1067 | + " \"name\": \"userId\",\n"+ |
| 1068 | + " \"description\": \"用户id\",\n"+ |
| 1069 | + " \"default\": 82001\n"+ |
| 1070 | + " },\n"+ |
| 1071 | + " {\n"+ |
| 1072 | + " \"name\": \"momentId\",\n"+ |
| 1073 | + " \"description\": \"动态id\",\n"+ |
| 1074 | + " \"default\": 15\n"+ |
| 1075 | + " },\n"+ |
| 1076 | + " {\n"+ |
| 1077 | + " \"name\": \"conent\",\n"+ |
| 1078 | + " \"description\": \"内容\",\n"+ |
| 1079 | + " \"default\": \"测试评论\"\n"+ |
| 1080 | + " }\n"+ |
| 1081 | + " ]\n"+ |
| 1082 | + " }\n"+ |
| 1083 | + " }\n"+ |
| 1084 | + " }\n"+ |
| 1085 | + "}"; |
1025 | 1086 | }
|
1026 | 1087 |
|
1027 | 1088 | }
|
0 commit comments