fix(接口自动化): 修复JSON 格式数据请求问题

This commit is contained in:
fit2-zhao 2021-01-11 15:11:24 +08:00
parent bcbc9e5a53
commit 869b66e551
2 changed files with 12 additions and 2 deletions

View File

@ -42,11 +42,13 @@ public class Body {
return true;
} else return false;
}
public boolean isOldKV() {
if (StringUtils.equals(type, KV)) {
return true;
} else return false;
}
public List<KeyValue> getBodyParams(HTTPSamplerProxy sampler, String requestId) {
List<KeyValue> body = new ArrayList<>();
if (this.isKV() || this.isBinary()) {
@ -65,7 +67,7 @@ public class Body {
this.raw = JSONSchemaGenerator.getJson(com.alibaba.fastjson.JSON.toJSONString(this.getJsonSchema()));
}
}
KeyValue keyValue = new KeyValue("", this.getRaw());
KeyValue keyValue = new KeyValue("", "JSON-SCHEMA", this.getRaw(), true, true);
keyValue.setEnable(true);
keyValue.setEncode(false);
body.add(keyValue);

View File

@ -31,6 +31,14 @@ public class KeyValue {
this(name, value, description, null);
}
public KeyValue(String name, String type, String value, boolean required, boolean enable) {
this.name = name;
this.type = type;
this.value = value;
this.required = required;
this.enable = enable;
}
public KeyValue(String name, String value, String description, String contentType) {
this(name, value, description, contentType, true);
}
@ -49,7 +57,7 @@ public class KeyValue {
}
public boolean isValid() {
return (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) && !StringUtils.equalsIgnoreCase(type, "file");
return ((StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) || "JSON-SCHEMA".equals(type)) && !StringUtils.equalsIgnoreCase(type, "file");
}
public boolean isFile() {