diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java b/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java index 6e23699cd6..0e812724d8 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java @@ -295,7 +295,6 @@ public class Swagger3Parser extends SwaggerAbstractParser { } private void parseKvBody(Schema schema, Body body, Object data, Map infoMap) { - if (data == null) return; if (data instanceof JSONObject) { ((JSONObject) data).forEach((k, v) -> { Schema dataSchema = (Schema) v; @@ -312,22 +311,21 @@ public class Swagger3Parser extends SwaggerAbstractParser { body.getKvs().add(kv); }); } else { - if (data instanceof String && StringUtils.isBlank((String) data)) { - return; - } - Schema dataSchema = (Schema) data; - KeyValue kv = new KeyValue(schema.getName(), String.valueOf(dataSchema.getExample()), schema.getDescription()); - Schema schemaInfo = infoMap.get(schema.getName()); - if (schemaInfo != null) { - if (schemaInfo instanceof BinarySchema) { - kv.setType("file"); + if(data instanceof Schema) { + Schema dataSchema = (Schema) data; + KeyValue kv = new KeyValue(schema.getName(), String.valueOf(dataSchema.getExample()), schema.getDescription()); + Schema schemaInfo = infoMap.get(schema.getName()); + if (schemaInfo != null) { + if (schemaInfo instanceof BinarySchema) { + kv.setType("file"); + } } - } - if (body != null) { - if (body.getKvs() == null) { - body.setKvs(new ArrayList<>()); + if (body != null) { + if (body.getKvs() == null) { + body.setKvs(new ArrayList<>()); + } + body.getKvs().add(kv); } - body.getKvs().add(kv); } } } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index 9d06f093f4..96351a3bf3 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -582,7 +582,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { * @return */ private boolean isCustomizeReqCompleteUrl(String url) { - if (isCustomizeReq() && (url.startsWith("http://") || url.startsWith("https://"))) { + if (isCustomizeReq() && StringUtils.isNotEmpty(url) && (url.startsWith("http://") || url.startsWith("https://"))) { return true; } return false;