fix(接口测试): 修复json-schema预览报错空指针的缺陷

--bug=1033026 --user=王孝刚
【接口测试】接口定义-编辑接口的请求体的json-schema格式,导入后模版和预览显示还是原始的
https://www.tapd.cn/55049933/s/1437834
This commit is contained in:
wxg0103 2023-11-20 18:11:17 +08:00 committed by wxg0103
parent 7b6f3ffdbc
commit 8647eaaecb
2 changed files with 11 additions and 6 deletions

View File

@ -50,8 +50,11 @@ public class JSONSchemaBuilder {
} else if (object.has(PropertyConstant.TYPE)) {
if (object.get(PropertyConstant.TYPE).getAsString().equals(PropertyConstant.ARRAY)) {
analyzeProperty(rootObj, PropertyConstant.MS_OBJECT, object, map);
} else if (!object.get(PropertyConstant.TYPE).getAsString().equals(PropertyConstant.OBJECT)) {
} else if (!object.get(PropertyConstant.TYPE).getAsString().equals(PropertyConstant.OBJECT) && !(object instanceof JsonObject)) {
String asString = object.getAsString();
analyzeProperty(rootObj, object.getAsString(), object, map);
} else {
formatObject(map, object, rootObj);
}
}
}
@ -256,7 +259,7 @@ public class JSONSchemaBuilder {
}
private static void formatObject(Map<String, String> map, JsonObject jsonObject, JSONObject concept) {
JsonObject propertiesObj = jsonObject.get(PropertyConstant.PROPERTIES).getAsJsonObject();
JsonObject propertiesObj = jsonObject.has(PropertyConstant.PROPERTIES) ? jsonObject.get(PropertyConstant.PROPERTIES).getAsJsonObject(): new JsonObject();
for (Entry<String, JsonElement> entry : propertiesObj.entrySet()) {
String propertyKey = entry.getKey();
JsonObject propertyObj = propertiesObj.get(propertyKey).getAsJsonObject();

View File

@ -251,7 +251,7 @@
</div>
</div>
<div class="card-content">
<div class="card-content white-space" >
<!-- 场景步骤-->
<div v-loading="loading">
<el-row>
@ -1512,12 +1512,14 @@ export default {
this.showAll();
this.buttonData = buttons(this);
this.initPlugins();
if (e && e.target.className && e.target.className.split(" ")[1] === "white--space") {
this.selectedTreeNode = undefined;
this.selectedNode = undefined;
}
},
fabClick() {
if (this.operatingElements && this.operatingElements.length < 1) {
if ((this.selectedTreeNode && this.selectedTreeNode.referenced === 'REF') || (this.selectedTreeNode.disabled && this.selectedTreeNode.disabled)) {
if ((this.selectedTreeNode && this.selectedTreeNode.referenced === 'REF') || (this.selectedNode.disabled && this.selectedTreeNode.disabled)) {
this.$warning(this.$t('api_test.scenario.scenario_warning'));
} else {
this.$warning(this.$t('api_test.scenario.scenario_step_warning'));