From 8647eaaecbc52961463badffd6af33d5d94ed292 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Mon, 20 Nov 2023 18:11:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Djson-schema=E9=A2=84=E8=A7=88=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E7=A9=BA=E6=8C=87=E9=92=88=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1033026 --user=王孝刚 【接口测试】接口定义-编辑接口的请求体的json-schema格式,导入后模版和预览显示还是原始的 https://www.tapd.cn/55049933/s/1437834 --- .../api/exec/generator/JSONSchemaBuilder.java | 7 +++++-- .../business/automation/scenario/EditApiScenario.vue | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/generator/JSONSchemaBuilder.java b/api-test/backend/src/main/java/io/metersphere/api/exec/generator/JSONSchemaBuilder.java index fc0b7c657d..04f116a5dd 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/generator/JSONSchemaBuilder.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/generator/JSONSchemaBuilder.java @@ -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 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 entry : propertiesObj.entrySet()) { String propertyKey = entry.getKey(); JsonObject propertyObj = propertiesObj.get(propertyKey).getAsJsonObject(); diff --git a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue index 7604cce8d1..6b69225efc 100644 --- a/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue +++ b/api-test/frontend/src/business/automation/scenario/EditApiScenario.vue @@ -251,7 +251,7 @@ -
+
@@ -1512,12 +1512,14 @@ export default { this.showAll(); this.buttonData = buttons(this); this.initPlugins(); - this.selectedTreeNode = undefined; - this.selectedNode = undefined; + 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'));