From 441e33722f4eb7fe28262506a271ba1dfd095824 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Sat, 8 May 2021 17:47:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=B7=E6=B1=82=E4=BD=93=E9=80=89xml?= =?UTF-8?q?=E7=AD=89=E6=A0=BC=E5=BC=8F=E8=BF=98=E6=98=AFjsonSchema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/dto/scenario/Body.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 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 a99554acda..285c2b9aba 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 @@ -81,13 +81,15 @@ public class Body { private void parseJonBodyMock() { try { - 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); + if (StringUtils.isNotBlank(this.type) && StringUtils.equals(this.type, "JSON")) { + 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 { // json 文本也支持 mock 参数 + JSONObject jsonObject = com.alibaba.fastjson.JSON.parseObject(this.getRaw()); + jsonMockParse(jsonObject); + this.raw = JSONObject.toJSONString(jsonObject); + } } } catch (Exception e) { LogUtil.error(e.getMessage(), e);