|
|
@@ -1,6 +1,8 @@
|
|
|
package com.github.microservice.utils;
|
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.github.microservice.models.openAPI.OpenApiInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
@@ -14,8 +16,8 @@ import java.util.List;
|
|
|
@Slf4j
|
|
|
public class OpenAPIScan {
|
|
|
|
|
|
- public static List<JSONObject> scanAPI(String str) {
|
|
|
- List<JSONObject> openAPIS = new ArrayList<>();
|
|
|
+ public static List<OpenApiInfo> scanAPI(String str) {
|
|
|
+ List<OpenApiInfo> openAPIS = new ArrayList<>();
|
|
|
try {
|
|
|
JSONObject jsonObject = new JSONObject(str);
|
|
|
JSONObject schemas = new JSONObject();
|
|
|
@@ -99,14 +101,15 @@ public class OpenAPIScan {
|
|
|
response = finalSchemas.getJSONObject(responseKey);
|
|
|
}
|
|
|
}
|
|
|
- JSONObject openAPI = new JSONObject();
|
|
|
- openAPI.put("method", method);
|
|
|
- openAPI.put("path", key);
|
|
|
- openAPI.set("params", params);
|
|
|
- openAPI.set("response", response);
|
|
|
- openAPI.set("description", object.get("description"));
|
|
|
- openAPI.set("summary", object.get("summary"));
|
|
|
- openAPI.set("operationId", object.get("operationId"));
|
|
|
+ OpenApiInfo openAPI = new OpenApiInfo();
|
|
|
+ openAPI.setPath(key);
|
|
|
+ openAPI.setRequestMethod(method);
|
|
|
+ openAPI.setContentType("application/json");
|
|
|
+ openAPI.setDescription(object.getStr("description"));
|
|
|
+ openAPI.setName(object.getStr("operationId"));
|
|
|
+ openAPI.setGroup("一卡通平台");
|
|
|
+ openAPI.setRequestParam(JSONUtil.toJsonStr(params));
|
|
|
+ openAPI.setResponseParam(JSONUtil.toJsonStr(response));
|
|
|
openAPIS.add(openAPI);
|
|
|
}
|
|
|
});
|