fix: 请求体选xml等格式还是jsonSchema

This commit is contained in:
chenjianxing 2021-05-08 17:47:28 +08:00 committed by jianxing
parent 66e6784bd3
commit 0114fab26a
1 changed files with 9 additions and 7 deletions

View File

@ -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);