导入swagger
This commit is contained in:
@@ -3,6 +3,7 @@ package com.test.test.service.impl;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.test.common.utils.DateUtils;
|
||||
import com.test.common.utils.http.HttpUtils;
|
||||
@@ -69,6 +70,7 @@ public class TestApiServiceImpl implements ITestApiService {
|
||||
AtomicInteger count = new AtomicInteger();
|
||||
JSONObject jsonObject = JSONObject.parseObject(HttpUtils.sendGet(url));
|
||||
String title = jsonObject.getJSONObject("info").getString("title");
|
||||
Date createTime = DateUtils.getNowDate();
|
||||
// 设置顶级节点
|
||||
Long parentId = getGroupId(title, 0L);
|
||||
// 获取Schemas
|
||||
@@ -101,12 +103,22 @@ public class TestApiServiceImpl implements ITestApiService {
|
||||
}
|
||||
}
|
||||
// 获取Param
|
||||
String param = "";
|
||||
String param = "[]";
|
||||
JSONObject parameters = json.getJSONObject("parameters");
|
||||
if (parameters!=null) {
|
||||
if (parameters != null) {
|
||||
JSONObject paramsJson = parseParams(parameters, schemas);
|
||||
param = JSONObject.toJSONString(paramsJson);
|
||||
JSONArray array = new JSONArray();
|
||||
paramsJson.forEach((key, value) -> {
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("key", key);
|
||||
object.put("value", value);
|
||||
array.add(object);
|
||||
});
|
||||
param = array.toJSONString();
|
||||
}
|
||||
// 获取header
|
||||
String header = "[]";
|
||||
|
||||
TestApi testApi = new TestApi();
|
||||
testApi.setUri(uri);
|
||||
testApi.setMethod(method);
|
||||
@@ -114,6 +126,8 @@ public class TestApiServiceImpl implements ITestApiService {
|
||||
testApi.setGroupId(getGroupId(groupName, parentId));
|
||||
testApi.setBody(body);
|
||||
testApi.setParam(param);
|
||||
testApi.setHeader(header);
|
||||
testApi.setCreateTime(createTime);
|
||||
|
||||
count.addAndGet(testApiMapper.insertTestApi(testApi));
|
||||
});
|
||||
|
||||
@@ -32,7 +32,14 @@ export default {
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: 'Loading',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
importApi({url: this.form.url}).then((res) => {
|
||||
loading.close();
|
||||
this.$message.success("导入成功")
|
||||
this.cancel();
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user