From 2f7b69ef275022547363c4aecf6b779baa1ee6ab Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Sat, 8 May 2021 16:37:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20jsonSchema=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/metersphere/api/dto/scenario/Body.java | 13 +++++-------- .../main/resources/i18n/messages_en_US.properties | 2 +- .../main/resources/i18n/messages_zh_CN.properties | 2 +- .../main/resources/i18n/messages_zh_TW.properties | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java index ebfa88aac5..a99554acda 100644 --- a/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java +++ b/backend/src/main/java/io/metersphere/api/dto/scenario/Body.java @@ -2,6 +2,7 @@ package io.metersphere.api.dto.scenario; import com.alibaba.fastjson.JSONObject; import io.metersphere.api.dto.scenario.request.BodyFile; +import io.metersphere.commons.json.JSONSchemaGenerator; import io.metersphere.commons.utils.FileUtils; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.ScriptEngineUtils; @@ -80,14 +81,10 @@ public class Body { private void parseJonBodyMock() { try { -// if (StringUtils.isNotBlank(this.format) && "JSON-SCHEMA".equals(this.format) ) { -// if(this.getJsonSchema() != null) { -// JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(this.getJsonSchema())); -// jsonMockParse(jsonObject); -// this.setJsonSchema(jsonObject); -// } -// } else - if (StringUtils.isNotBlank(this.type) && StringUtils.equals(this.type, "JSON")) { // json 文本也支持 mock 参数 + if(StringUtils.isNotEmpty(this.format) && this.getJsonSchema() != null + && "JSON-SCHEMA".equals(this.format)) { + this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema())); + } else if (StringUtils.isNotBlank(this.type) && StringUtils.equals(this.type, "JSON")) { // json 文本也支持 mock 参数 JSONObject jsonObject = com.alibaba.fastjson.JSON.parseObject(this.getRaw()); jsonMockParse(jsonObject); this.raw = JSONObject.toJSONString(jsonObject); diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 9b5fee7017..ffdfcc9ab2 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -210,7 +210,7 @@ task_notification_jenkins=Jenkins Task notification task_notification=Result notification message_task_already_exists=Task recipient already exists #automation -automation_name_already_exists=the scenario already exists in the project and the module +automation_name_already_exists=the scenario already exists in the project automation_exec_info=There are no test steps to execute #authsource authsource_name_already_exists=Authentication source name already exists diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index bd455eb94e..587535645b 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -211,7 +211,7 @@ task_notification_jenkins=jenkins任务通知 task_notification=任务通知 message_task_already_exists=任务接收人已经存在 #automation -automation_name_already_exists=同一个项目和模块下,场景名称不能重复 +automation_name_already_exists=同一个项目下,场景名称不能重复 automation_exec_info=没有测试步骤,无法执行 #authsource authsource_name_already_exists=认证源名称已经存在 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 9fc873a7f4..f8edac47c1 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -212,7 +212,7 @@ task_notification_=定時任務通知 api_definition_url_not_repeating=接口請求地址已經存在 message_task_already_exists=任務接收人已經存在 #automation -automation_name_already_exists=同一個項目和模塊下,場景名稱不能重複 +automation_name_already_exists=同一個項目下,場景名稱不能重複 automation_exec_info=沒有測試步驟,無法執行 #authsource authsource_name_already_exists=認證源名稱已經存在