fix(接口自动化): 修复swagger导入问题

This commit is contained in:
fit2-zhao 2021-11-16 13:18:37 +08:00 committed by fit2-zhao
parent 8f27fedcfe
commit fdeb2d4b23
2 changed files with 14 additions and 16 deletions

View File

@ -295,7 +295,6 @@ public class Swagger3Parser extends SwaggerAbstractParser {
} }
private void parseKvBody(Schema schema, Body body, Object data, Map<String, Schema> infoMap) { private void parseKvBody(Schema schema, Body body, Object data, Map<String, Schema> infoMap) {
if (data == null) return;
if (data instanceof JSONObject) { if (data instanceof JSONObject) {
((JSONObject) data).forEach((k, v) -> { ((JSONObject) data).forEach((k, v) -> {
Schema dataSchema = (Schema) v; Schema dataSchema = (Schema) v;
@ -312,9 +311,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
body.getKvs().add(kv); body.getKvs().add(kv);
}); });
} else { } else {
if (data instanceof String && StringUtils.isBlank((String) data)) { if(data instanceof Schema) {
return;
}
Schema dataSchema = (Schema) data; Schema dataSchema = (Schema) data;
KeyValue kv = new KeyValue(schema.getName(), String.valueOf(dataSchema.getExample()), schema.getDescription()); KeyValue kv = new KeyValue(schema.getName(), String.valueOf(dataSchema.getExample()), schema.getDescription());
Schema schemaInfo = infoMap.get(schema.getName()); Schema schemaInfo = infoMap.get(schema.getName());
@ -331,6 +328,7 @@ public class Swagger3Parser extends SwaggerAbstractParser {
} }
} }
} }
}
private String parseXmlBody(Schema schema, Object data) { private String parseXmlBody(Schema schema, Object data) {
if (data instanceof JSONObject) { if (data instanceof JSONObject) {

View File

@ -582,7 +582,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
* @return * @return
*/ */
private boolean isCustomizeReqCompleteUrl(String url) { 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 true;
} }
return false; return false;