From 1b161e3cac1696c2302102956be8f52afa5ab56f Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Mon, 15 Nov 2021 16:55:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(TCP-Mock=E3=80=81Json-schema):=20#1007848?= =?UTF-8?q?=20=E3=80=90github#7666=E3=80=91TCP=20mock=E7=9A=84json=20raw?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=97=A0=E5=93=8D=E5=BA=94=E3=80=81jesonsche?= =?UTF-8?q?ma=E8=BD=AC=E6=8D=A2=E6=97=B6=E5=81=A5=E7=9A=84=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E9=94=99=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1007848 --user=宋天阳 【github#7666】TCP mock的json raw点击无响应 https://www.tapd.cn/55049933/s/1067738、jesonschema转换时健的顺序错序 --- .../io/metersphere/commons/json/JSONSchemaGenerator.java | 8 ++++---- .../api/definition/components/mock/MockEditDrawer.vue | 1 + .../components/common/json-schema/schema/editor/main.vue | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/commons/json/JSONSchemaGenerator.java b/backend/src/main/java/io/metersphere/commons/json/JSONSchemaGenerator.java index a5dc2a7baa..ce05d68f0f 100644 --- a/backend/src/main/java/io/metersphere/commons/json/JSONSchemaGenerator.java +++ b/backend/src/main/java/io/metersphere/commons/json/JSONSchemaGenerator.java @@ -210,7 +210,7 @@ public class JSONSchemaGenerator { array.add(0); } } else if (itemsObject.has("properties")) { - JSONObject propertyConcept = new JSONObject(); + JSONObject propertyConcept = new JSONObject(true); JsonObject propertiesObj = itemsObject.get("properties").getAsJsonObject(); for (Entry entry : propertiesObj.entrySet()) { String propertyKey = entry.getKey(); @@ -229,13 +229,13 @@ public class JSONSchemaGenerator { array.add(itemsObjectArray); } } - concept.put(propertyName, array); - } else if (propertyObjType.equals("object")) { JSONObject obj = new JSONObject(); concept.put(propertyName, obj); analyzeObject(object, obj); + } else if (StringUtils.equalsIgnoreCase(propertyObjType,"null")) { + concept.put(propertyName, null); } } } @@ -274,7 +274,7 @@ public class JSONSchemaGenerator { private static String formerJson(String jsonSchema) { try { - JSONObject root = new JSONObject(); + JSONObject root = new JSONObject(true); generator(jsonSchema, root); // 格式化返回 Gson gson = new GsonBuilder().serializeNulls().setPrettyPrinting().disableHtmlEscaping().create(); diff --git a/frontend/src/business/components/api/definition/components/mock/MockEditDrawer.vue b/frontend/src/business/components/api/definition/components/mock/MockEditDrawer.vue index 451b765c74..9ce1d74c26 100644 --- a/frontend/src/business/components/api/definition/components/mock/MockEditDrawer.vue +++ b/frontend/src/business/components/api/definition/components/mock/MockEditDrawer.vue @@ -86,6 +86,7 @@ export default { name: "", mockConfigId: "", request: { + reportType: "raw", jsonParam: false, variables: [], jsonData: "{}", diff --git a/frontend/src/business/components/common/json-schema/schema/editor/main.vue b/frontend/src/business/components/common/json-schema/schema/editor/main.vue index 433c9f72e3..a319706880 100644 --- a/frontend/src/business/components/common/json-schema/schema/editor/main.vue +++ b/frontend/src/business/components/common/json-schema/schema/editor/main.vue @@ -21,7 +21,7 @@ - +