fix(接口测试): 修复文档分享中jsonschema参数的显示问题

--bug=1012866 --user=宋天阳 【接口测试】github#13138,分享出来的接口没有描述信息 json结构图多了个0
https://www.tapd.cn/55049933/s/1153420
This commit is contained in:
song-tianyang 2022-05-06 14:53:32 +08:00 committed by TIanyang
parent e4411ded9a
commit dfcb463ebf
4 changed files with 26 additions and 11 deletions

View File

@ -31,7 +31,7 @@ public class ApiDocumentInfoDTO {
private String requestBodyFormData;
private String requestBodyStrutureData;
private Object requestPreviewData;
private String jsonSchemaBody;
private JSONSchemaBodyDTO jsonSchemaBody;
private String responseHead;
private String responseBody;

View File

@ -0,0 +1,11 @@
package io.metersphere.api.dto.share;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class JSONSchemaBodyDTO {
private Object jsonSchema;
private String raw;
}

View File

@ -210,12 +210,21 @@ public class ShareInfoService {
isJsonSchema = true;
}
}
if (bodyObj.containsKey("raw")) {
String raw = bodyObj.getString("raw");
apiInfoDTO.setJsonSchemaBody(raw);
apiInfoDTO.setRequestBodyStrutureData(raw);
//转化jsonObje 或者 jsonArray
JSONSchemaBodyDTO jsonSchemaBodyDTO = new JSONSchemaBodyDTO();
if(isJsonSchema){
jsonSchemaBodyDTO.setJsonSchema(bodyObj.get("jsonSchema"));
apiInfoDTO.setJsonSchemaBody(jsonSchemaBodyDTO);
String raw =JSONSchemaGenerator.getJson(JSONObject.toJSONString(bodyObj.get("jsonSchema")));
this.setPreviewData(previewJsonArray, raw);
}else {
if (bodyObj.containsKey("raw")) {
String raw = bodyObj.getString("raw");
jsonSchemaBodyDTO.setRaw(raw);
apiInfoDTO.setJsonSchemaBody(jsonSchemaBodyDTO);
apiInfoDTO.setRequestBodyStrutureData(raw);
//转化jsonObje 或者 jsonArray
this.setPreviewData(previewJsonArray, raw);
}
}
} else if (StringUtils.equalsAny(type, "XML", "Raw")) {
if (bodyObj.containsKey("raw")) {
@ -330,8 +339,6 @@ public class ShareInfoService {
if (bodyObj.containsKey("raw")) {
String raw = bodyObj.getString("raw");
apiInfoDTO.setResponseBodyStrutureData(raw);
//转化jsonObje 或者 jsonArray
this.setPreviewData(previewJsonArray, raw);
}
}
} else if (StringUtils.equalsAny(type, "Form Data", "WWW_FORM")) {

View File

@ -332,9 +332,6 @@ export default {
for (let dataIndex = 0; dataIndex < returnDatas.length; dataIndex++) {
let index = indexArr[dataIndex];
let data = returnDatas[dataIndex];
if (data.jsonSchemaBody) {
data.jsonSchemaBody = {raw:data.jsonSchemaBody};
}
this.$set(this.apiInfoArray, index, data);
}
this.updateShowArray(itemIndex, afterNodeIndex, beforeNodeIndex);