Merge remote-tracking branch 'origin/v1.8' into v1.8
This commit is contained in:
commit
612d8438c9
|
@ -136,8 +136,10 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
|||
try {
|
||||
HTTPSamplerProxy source = (HTTPSamplerProxy) key;
|
||||
BeanUtils.copyBean(samplerProxy, source);
|
||||
samplerProxy.setRest(new ArrayList<KeyValue>(){{this.add(new KeyValue());}});
|
||||
samplerProxy.setArguments(new ArrayList<KeyValue>(){{this.add(new KeyValue());}});
|
||||
if (source != null && source.getHTTPFiles().length > 0) {
|
||||
samplerProxy.getBody().setBinary(new ArrayList<>());
|
||||
samplerProxy.getBody().initBinary();
|
||||
samplerProxy.getBody().setType(Body.FORM_DATA);
|
||||
List<KeyValue> keyValues = new LinkedList<>();
|
||||
for (HTTPFileArg arg : source.getHTTPFiles()) {
|
||||
|
@ -163,6 +165,7 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
|||
source.getArguments().getArgumentsAsMap().forEach((k, v) -> {
|
||||
samplerProxy.getBody().setRaw(v);
|
||||
});
|
||||
samplerProxy.getBody().initKvs();
|
||||
} else {
|
||||
List<KeyValue> keyValues = new LinkedList<>();
|
||||
source.getArguments().getArgumentsAsMap().forEach((k, v) -> {
|
||||
|
@ -173,6 +176,7 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
|||
samplerProxy.setArguments(keyValues);
|
||||
}
|
||||
}
|
||||
samplerProxy.getBody().initBinary();
|
||||
}
|
||||
samplerProxy.setPath("");
|
||||
samplerProxy.setMethod(source.getMethod());
|
||||
|
|
|
@ -66,14 +66,11 @@ public class Body {
|
|||
sampler.setDoMultipart(true);
|
||||
}
|
||||
} else {
|
||||
if (!this.isJson()) {
|
||||
sampler.setPostBodyRaw(true);
|
||||
} else {
|
||||
if (StringUtils.isNotEmpty(this.format) && "JSON-SCHEMA".equals(this.format) && this.getJsonSchema() != null) {
|
||||
this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema()));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(this.format) && "JSON-SCHEMA".equals(this.format) && this.getJsonSchema() != null) {
|
||||
this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema()));
|
||||
}
|
||||
KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true);
|
||||
sampler.setPostBodyRaw(true);
|
||||
keyValue.setEnable(true);
|
||||
keyValue.setEncode(false);
|
||||
body.add(keyValue);
|
||||
|
|
|
@ -86,216 +86,240 @@ public class ApiDocumentService {
|
|||
apiInfoDTO.setStatus(apiModel.getStatus());
|
||||
|
||||
if (apiModel.getRequest() != null) {
|
||||
JSONObject requestJsonObj = JSONObject.parseObject(apiModel.getRequest());
|
||||
//head赋值conversionModelToDTO
|
||||
if (requestJsonObj.containsKey("headers")) {
|
||||
JSONArray requestHeadDataArr = new JSONArray();
|
||||
//head赋值
|
||||
JSONArray headArr = requestJsonObj.getJSONArray("headers");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
requestHeadDataArr.add(headObj);
|
||||
JSONObject requestObj = this.genJSONObject(apiModel.getRequest());
|
||||
if(requestObj!=null){
|
||||
if (requestObj.containsKey("headers")) {
|
||||
JSONArray requestHeadDataArr = new JSONArray();
|
||||
//head赋值
|
||||
JSONArray headArr = requestObj.getJSONArray("headers");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
requestHeadDataArr.add(headObj);
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setRequestHead(requestHeadDataArr.toJSONString());
|
||||
}
|
||||
apiInfoDTO.setRequestHead(requestHeadDataArr.toJSONString());
|
||||
}
|
||||
//url参数赋值
|
||||
JSONArray urlParamArr = new JSONArray();
|
||||
if (requestJsonObj.containsKey("arguments")) {
|
||||
//urlParam -- query赋值
|
||||
JSONArray headArr = requestJsonObj.getJSONArray("arguments");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
urlParamArr.add(headObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (requestJsonObj.containsKey("rest")) {
|
||||
//urlParam -- rest赋值
|
||||
JSONArray headArr = requestJsonObj.getJSONArray("rest");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
urlParamArr.add(headObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setUrlParams(urlParamArr.toJSONString());
|
||||
//请求体参数类型
|
||||
if (requestJsonObj.containsKey("body")) {
|
||||
JSONObject bodyObj = requestJsonObj.getJSONObject("body");
|
||||
if (bodyObj.containsKey("type")) {
|
||||
String type = bodyObj.getString("type");
|
||||
if (StringUtils.equals(type, "WWW_FORM")) {
|
||||
apiInfoDTO.setRequestBodyParamType("x-www-from-urlencoded");
|
||||
} else if (StringUtils.equals(type, "Form Data")) {
|
||||
apiInfoDTO.setRequestBodyParamType("form-data");
|
||||
} else {
|
||||
apiInfoDTO.setRequestBodyParamType(type);
|
||||
}
|
||||
//url参数赋值
|
||||
JSONArray urlParamArr = new JSONArray();
|
||||
if (requestObj.containsKey("arguments")) {
|
||||
try{
|
||||
JSONArray headArr = requestObj.getJSONArray("arguments");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
|
||||
if (StringUtils.equals(type, "JSON")) {
|
||||
//判断是否是JsonSchema
|
||||
boolean isJsonSchema = false;
|
||||
if (bodyObj.containsKey("format")) {
|
||||
String foramtValue = String.valueOf(bodyObj.get("format"));
|
||||
if (StringUtils.equals("JSON-SCHEMA", foramtValue)) {
|
||||
isJsonSchema = true;
|
||||
}
|
||||
}
|
||||
if (isJsonSchema) {
|
||||
apiInfoDTO.setRequestBodyParamType("JSON-SCHEMA");
|
||||
apiInfoDTO.setJsonSchemaBody(bodyObj);
|
||||
} else {
|
||||
if (bodyObj.containsKey("raw")) {
|
||||
String raw = bodyObj.getString("raw");
|
||||
apiInfoDTO.setRequestBodyStrutureData(raw);
|
||||
//转化jsonObje 或者 jsonArray
|
||||
this.setPreviewData(previewJsonArray, raw);
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.equalsAny(type, "XML", "Raw")) {
|
||||
if (bodyObj.containsKey("raw")) {
|
||||
String raw = bodyObj.getString("raw");
|
||||
apiInfoDTO.setRequestBodyStrutureData(raw);
|
||||
JSONObject previewObj = JSONObject.parseObject(raw);
|
||||
this.setPreviewData(previewJsonArray, raw);
|
||||
}
|
||||
} else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) {
|
||||
if (bodyObj.containsKey("kvs")) {
|
||||
JSONArray bodyParamArr = new JSONArray();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("kvs");
|
||||
Map<String, String> previewObjMap = new LinkedHashMap<>();
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("name") && kv.containsKey("value")) {
|
||||
bodyParamArr.add(kv);
|
||||
previewObjMap.put(String.valueOf(kv.get("name")), String.valueOf(kv.get("value")));
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
urlParamArr.add(headObj);
|
||||
}
|
||||
}
|
||||
this.setPreviewData(previewJsonArray, JSONObject.toJSONString(previewObjMap));
|
||||
apiInfoDTO.setRequestBodyFormData(bodyParamArr.toJSONString());
|
||||
}
|
||||
} else if (StringUtils.equals(type, "BINARY")) {
|
||||
if (bodyObj.containsKey("binary")) {
|
||||
List<Map<String, String>> bodyParamList = new ArrayList<>();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("binary");
|
||||
}catch (Exception e){
|
||||
}
|
||||
}
|
||||
if (requestObj.containsKey("rest")) {
|
||||
try{
|
||||
//urlParam -- rest赋值
|
||||
JSONArray headArr = requestObj.getJSONArray("rest");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
urlParamArr.add(headObj);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setUrlParams(urlParamArr.toJSONString());
|
||||
//请求体参数类型
|
||||
if (requestObj.containsKey("body")) {
|
||||
try{
|
||||
JSONObject bodyObj = requestObj.getJSONObject("body");
|
||||
if (bodyObj.containsKey("type")) {
|
||||
String type = bodyObj.getString("type");
|
||||
if (StringUtils.equals(type, "WWW_FORM")) {
|
||||
apiInfoDTO.setRequestBodyParamType("x-www-from-urlencoded");
|
||||
} else if (StringUtils.equals(type, "Form Data")) {
|
||||
apiInfoDTO.setRequestBodyParamType("form-data");
|
||||
} else {
|
||||
apiInfoDTO.setRequestBodyParamType(type);
|
||||
}
|
||||
|
||||
Map<String, String> previewObjMap = new LinkedHashMap<>();
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("description") && kv.containsKey("files")) {
|
||||
Map<String, String> bodyMap = new HashMap<>();
|
||||
String name = kv.getString("description");
|
||||
JSONArray fileArr = kv.getJSONArray("files");
|
||||
String value = "";
|
||||
for (int j = 0; j < fileArr.size(); j++) {
|
||||
JSONObject fileObj = fileArr.getJSONObject(j);
|
||||
if (fileObj.containsKey("name")) {
|
||||
value += fileObj.getString("name") + " ;";
|
||||
if (StringUtils.equals(type, "JSON")) {
|
||||
//判断是否是JsonSchema
|
||||
boolean isJsonSchema = false;
|
||||
if (bodyObj.containsKey("format")) {
|
||||
String foramtValue = String.valueOf(bodyObj.get("format"));
|
||||
if (StringUtils.equals("JSON-SCHEMA", foramtValue)) {
|
||||
isJsonSchema = true;
|
||||
}
|
||||
}
|
||||
if (isJsonSchema) {
|
||||
apiInfoDTO.setRequestBodyParamType("JSON-SCHEMA");
|
||||
apiInfoDTO.setJsonSchemaBody(bodyObj);
|
||||
} else {
|
||||
if (bodyObj.containsKey("raw")) {
|
||||
String raw = bodyObj.getString("raw");
|
||||
apiInfoDTO.setRequestBodyStrutureData(raw);
|
||||
//转化jsonObje 或者 jsonArray
|
||||
this.setPreviewData(previewJsonArray, raw);
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.equalsAny(type, "XML", "Raw")) {
|
||||
if (bodyObj.containsKey("raw")) {
|
||||
String raw = bodyObj.getString("raw");
|
||||
apiInfoDTO.setRequestBodyStrutureData(raw);
|
||||
this.setPreviewData(previewJsonArray, raw);
|
||||
}
|
||||
} else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) {
|
||||
if (bodyObj.containsKey("kvs")) {
|
||||
JSONArray bodyParamArr = new JSONArray();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("kvs");
|
||||
Map<String, String> previewObjMap = new LinkedHashMap<>();
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("name") && kv.containsKey("value")) {
|
||||
bodyParamArr.add(kv);
|
||||
previewObjMap.put(String.valueOf(kv.get("name")), String.valueOf(kv.get("value")));
|
||||
}
|
||||
}
|
||||
bodyMap.put("name", name);
|
||||
bodyMap.put("value", value);
|
||||
bodyMap.put("contentType", "File");
|
||||
bodyParamList.add(bodyMap);
|
||||
this.setPreviewData(previewJsonArray, JSONObject.toJSONString(previewObjMap));
|
||||
apiInfoDTO.setRequestBodyFormData(bodyParamArr.toJSONString());
|
||||
}
|
||||
} else if (StringUtils.equals(type, "BINARY")) {
|
||||
if (bodyObj.containsKey("binary")) {
|
||||
List<Map<String, String>> bodyParamList = new ArrayList<>();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("binary");
|
||||
|
||||
previewObjMap.put(String.valueOf(name), String.valueOf(value));
|
||||
Map<String, String> previewObjMap = new LinkedHashMap<>();
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("description") && kv.containsKey("files")) {
|
||||
Map<String, String> bodyMap = new HashMap<>();
|
||||
String name = kv.getString("description");
|
||||
JSONArray fileArr = kv.getJSONArray("files");
|
||||
String value = "";
|
||||
for (int j = 0; j < fileArr.size(); j++) {
|
||||
JSONObject fileObj = fileArr.getJSONObject(j);
|
||||
if (fileObj.containsKey("name")) {
|
||||
value += fileObj.getString("name") + " ;";
|
||||
}
|
||||
}
|
||||
bodyMap.put("name", name);
|
||||
bodyMap.put("value", value);
|
||||
bodyMap.put("contentType", "File");
|
||||
bodyParamList.add(bodyMap);
|
||||
|
||||
previewObjMap.put(String.valueOf(name), String.valueOf(value));
|
||||
|
||||
}
|
||||
}
|
||||
this.setPreviewData(previewJsonArray, JSONObject.toJSONString(previewObjMap));
|
||||
apiInfoDTO.setRequestBodyFormData(JSONArray.toJSONString(bodyParamList));
|
||||
}
|
||||
}
|
||||
this.setPreviewData(previewJsonArray, JSONObject.toJSONString(previewObjMap));
|
||||
apiInfoDTO.setRequestBodyFormData(JSONArray.toJSONString(bodyParamList));
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//赋值响应头
|
||||
if (apiModel.getResponse() != null) {
|
||||
JSONObject responseJsonObj = JSONObject.parseObject(apiModel.getResponse());
|
||||
JSONObject responseJsonObj = this.genJSONObject(apiModel.getResponse());
|
||||
if (responseJsonObj!=null && responseJsonObj.containsKey("headers")) {
|
||||
JSONArray responseHeadDataArr = new JSONArray();
|
||||
JSONArray headArr = responseJsonObj.getJSONArray("headers");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
responseHeadDataArr.add(headObj);
|
||||
try{
|
||||
JSONArray responseHeadDataArr = new JSONArray();
|
||||
JSONArray headArr = responseJsonObj.getJSONArray("headers");
|
||||
for (int index = 0; index < headArr.size(); index++) {
|
||||
JSONObject headObj = headArr.getJSONObject(index);
|
||||
if (headObj.containsKey("name") && headObj.containsKey("value")) {
|
||||
responseHeadDataArr.add(headObj);
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setResponseHead(responseHeadDataArr.toJSONString());
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
apiInfoDTO.setResponseHead(responseHeadDataArr.toJSONString());
|
||||
}
|
||||
// 赋值响应体
|
||||
if (responseJsonObj!=null && responseJsonObj.containsKey("body")) {
|
||||
JSONObject bodyObj = responseJsonObj.getJSONObject("body");
|
||||
if (bodyObj.containsKey("type")) {
|
||||
String type = bodyObj.getString("type");
|
||||
if (StringUtils.equals(type, "WWW_FORM")) {
|
||||
apiInfoDTO.setResponseBodyParamType("x-www-from-urlencoded");
|
||||
} else if (StringUtils.equals(type, "Form Data")) {
|
||||
apiInfoDTO.setResponseBodyParamType("form-data");
|
||||
} else {
|
||||
apiInfoDTO.setResponseBodyParamType(type);
|
||||
}
|
||||
if (StringUtils.equalsAny(type, "JSON", "XML", "Raw")) {
|
||||
if (bodyObj.containsKey("raw")) {
|
||||
String raw = bodyObj.getString("raw");
|
||||
apiInfoDTO.setResponseBodyStrutureData(raw);
|
||||
try {
|
||||
JSONObject bodyObj = responseJsonObj.getJSONObject("body");
|
||||
if (bodyObj.containsKey("type")) {
|
||||
String type = bodyObj.getString("type");
|
||||
if (StringUtils.equals(type, "WWW_FORM")) {
|
||||
apiInfoDTO.setResponseBodyParamType("x-www-from-urlencoded");
|
||||
} else if (StringUtils.equals(type, "Form Data")) {
|
||||
apiInfoDTO.setResponseBodyParamType("form-data");
|
||||
} else {
|
||||
apiInfoDTO.setResponseBodyParamType(type);
|
||||
}
|
||||
} else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) {
|
||||
if (bodyObj.containsKey("kvs")) {
|
||||
JSONArray bodyParamArr = new JSONArray();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("kvs");
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("name")) {
|
||||
bodyParamArr.add(kv);
|
||||
}
|
||||
if (StringUtils.equalsAny(type, "JSON", "XML", "Raw")) {
|
||||
if (bodyObj.containsKey("raw")) {
|
||||
String raw = bodyObj.getString("raw");
|
||||
apiInfoDTO.setResponseBodyStrutureData(raw);
|
||||
}
|
||||
apiInfoDTO.setResponseBodyFormData(bodyParamArr.toJSONString());
|
||||
}
|
||||
} else if (StringUtils.equals(type, "BINARY")) {
|
||||
if (bodyObj.containsKey("binary")) {
|
||||
List<Map<String, String>> bodyParamList = new ArrayList<>();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("kvs");
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("description") && kv.containsKey("files")) {
|
||||
Map<String, String> bodyMap = new HashMap<>();
|
||||
|
||||
String name = kv.getString("description");
|
||||
JSONArray fileArr = kv.getJSONArray("files");
|
||||
String value = "";
|
||||
for (int j = 0; j < fileArr.size(); j++) {
|
||||
JSONObject fileObj = fileArr.getJSONObject(j);
|
||||
if (fileObj.containsKey("name")) {
|
||||
value += fileObj.getString("name") + " ;";
|
||||
}
|
||||
} else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) {
|
||||
if (bodyObj.containsKey("kvs")) {
|
||||
JSONArray bodyParamArr = new JSONArray();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("kvs");
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("name")) {
|
||||
bodyParamArr.add(kv);
|
||||
}
|
||||
bodyMap.put("name", name);
|
||||
bodyMap.put("value", value);
|
||||
bodyParamList.add(bodyMap);
|
||||
}
|
||||
apiInfoDTO.setResponseBodyFormData(bodyParamArr.toJSONString());
|
||||
}
|
||||
} else if (StringUtils.equals(type, "BINARY")) {
|
||||
if (bodyObj.containsKey("binary")) {
|
||||
List<Map<String, String>> bodyParamList = new ArrayList<>();
|
||||
JSONArray kvsArr = bodyObj.getJSONArray("kvs");
|
||||
for (int i = 0; i < kvsArr.size(); i++) {
|
||||
JSONObject kv = kvsArr.getJSONObject(i);
|
||||
if (kv.containsKey("description") && kv.containsKey("files")) {
|
||||
Map<String, String> bodyMap = new HashMap<>();
|
||||
|
||||
String name = kv.getString("description");
|
||||
JSONArray fileArr = kv.getJSONArray("files");
|
||||
String value = "";
|
||||
for (int j = 0; j < fileArr.size(); j++) {
|
||||
JSONObject fileObj = fileArr.getJSONObject(j);
|
||||
if (fileObj.containsKey("name")) {
|
||||
value += fileObj.getString("name") + " ;";
|
||||
}
|
||||
}
|
||||
bodyMap.put("name", name);
|
||||
bodyMap.put("value", value);
|
||||
bodyParamList.add(bodyMap);
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setResponseBodyFormData(JSONArray.toJSONString(bodyParamList));
|
||||
}
|
||||
apiInfoDTO.setResponseBodyFormData(JSONArray.toJSONString(bodyParamList));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// 赋值响应码
|
||||
if (responseJsonObj!=null && responseJsonObj.containsKey("statusCode")) {
|
||||
JSONArray responseStatusDataArr = new JSONArray();
|
||||
JSONArray statusArr = responseJsonObj.getJSONArray("statusCode");
|
||||
for (int index = 0; index < statusArr.size(); index++) {
|
||||
JSONObject statusObj = statusArr.getJSONObject(index);
|
||||
if (statusObj.containsKey("name") && statusObj.containsKey("value")) {
|
||||
responseStatusDataArr.add(statusObj);
|
||||
try {
|
||||
JSONArray responseStatusDataArr = new JSONArray();
|
||||
JSONArray statusArr = responseJsonObj.getJSONArray("statusCode");
|
||||
for (int index = 0; index < statusArr.size(); index++) {
|
||||
JSONObject statusObj = statusArr.getJSONObject(index);
|
||||
if (statusObj.containsKey("name") && statusObj.containsKey("value")) {
|
||||
responseStatusDataArr.add(statusObj);
|
||||
}
|
||||
}
|
||||
apiInfoDTO.setResponseCode(responseStatusDataArr.toJSONString());
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
apiInfoDTO.setResponseCode(responseStatusDataArr.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -304,6 +328,15 @@ public class ApiDocumentService {
|
|||
return apiInfoDTO;
|
||||
}
|
||||
|
||||
private JSONObject genJSONObject(String request) {
|
||||
JSONObject returnObj = null;
|
||||
try{
|
||||
returnObj = JSONObject.parseObject(request);
|
||||
}catch (Exception e){
|
||||
}
|
||||
return returnObj;
|
||||
}
|
||||
|
||||
private void setPreviewData(JSONArray previewArray, String data) {
|
||||
try {
|
||||
JSONObject previewObj = JSONObject.parseObject(data);
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
<el-option v-for="(environment, index) in pe.envs" :key="index"
|
||||
:label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
|
||||
:value="environment.id"/>
|
||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id)">
|
||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
||||
{{ $t('api_test.environment.environment_config') }}
|
||||
</el-button>
|
||||
<template v-slot:empty>
|
||||
<div class="empty-environment">
|
||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id)">
|
||||
<el-button class="ms-scenario-button" size="mini" type="primary" @click="openEnvironmentConfig(pe.id, pe['selectEnv'])">
|
||||
{{ $t('api_test.environment.environment_config') }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
@ -78,12 +78,12 @@ export default {
|
|||
const project = this.projectList.find(p => p.id === id);
|
||||
return project ? project.name : "";
|
||||
},
|
||||
openEnvironmentConfig(projectId) {
|
||||
openEnvironmentConfig(projectId, envId) {
|
||||
if (!projectId) {
|
||||
this.$error(this.$t('api_test.select_project'));
|
||||
return;
|
||||
}
|
||||
this.$refs.environmentConfig.open(projectId);
|
||||
this.$refs.environmentConfig.open(projectId, envId);
|
||||
},
|
||||
handleConfirm() {
|
||||
let map = new Map();
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
this.$error(this.$t('api_test.select_project'));
|
||||
return;
|
||||
}
|
||||
this.$refs.environmentConfig.open(this.projectId);
|
||||
this.$refs.environmentConfig.open(this.projectId, this.environmentId);
|
||||
},
|
||||
environmentChange(value) {
|
||||
for (let i in this.environments) {
|
||||
|
|
|
@ -46,13 +46,15 @@
|
|||
icon: 'el-icon-delete',
|
||||
func: this.deleteEnvironment
|
||||
}
|
||||
]
|
||||
],
|
||||
selectEnvironmentId: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open: function (projectId) {
|
||||
open: function (projectId, envId) {
|
||||
this.visible = true;
|
||||
this.projectId = projectId;
|
||||
this.selectEnvironmentId = envId;
|
||||
this.getEnvironments();
|
||||
listenGoBack(this.close);
|
||||
},
|
||||
|
@ -114,7 +116,16 @@
|
|||
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
|
||||
this.environments = response.data;
|
||||
if (this.environments.length > 0) {
|
||||
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||
if (this.selectEnvironmentId) {
|
||||
const index = this.environments.findIndex(e => e.id === this.selectEnvironmentId);
|
||||
if (index !== -1) {
|
||||
this.$refs.environmentItems.itemSelected(index, this.environments[index]);
|
||||
} else {
|
||||
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||
}
|
||||
} else {
|
||||
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||
}
|
||||
} else {
|
||||
let item = new Environment({
|
||||
projectId: this.projectId
|
||||
|
|
|
@ -46,13 +46,15 @@
|
|||
icon: 'el-icon-delete',
|
||||
func: this.deleteEnvironment
|
||||
}
|
||||
]
|
||||
],
|
||||
selectEnvironmentId: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open: function (projectId) {
|
||||
open: function (projectId, envId) {
|
||||
this.visible = true;
|
||||
this.projectId = projectId;
|
||||
this.selectEnvironmentId = envId;
|
||||
this.getEnvironments();
|
||||
listenGoBack(this.close);
|
||||
},
|
||||
|
@ -114,7 +116,16 @@
|
|||
this.result = this.$get('/api/environment/list/' + this.projectId, response => {
|
||||
this.environments = response.data;
|
||||
if (this.environments.length > 0) {
|
||||
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||
if (this.selectEnvironmentId) {
|
||||
const index = this.environments.findIndex(e => e.id === this.selectEnvironmentId);
|
||||
if (index !== -1) {
|
||||
this.$refs.environmentItems.itemSelected(index, this.environments[index]);
|
||||
} else {
|
||||
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||
}
|
||||
} else {
|
||||
this.$refs.environmentItems.itemSelected(0, this.environments[0]);
|
||||
}
|
||||
} else {
|
||||
let item = new Environment({
|
||||
projectId: this.projectId
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2115bd28a90854d2b6276a90878934715498c584
|
||||
Subproject commit 07951ba17aef6f29e50cfd68e40de3266f9a60cd
|
Loading…
Reference in New Issue