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,22 +311,21 @@ 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;
} KeyValue kv = new KeyValue(schema.getName(), String.valueOf(dataSchema.getExample()), schema.getDescription());
Schema dataSchema = (Schema) data; Schema schemaInfo = infoMap.get(schema.getName());
KeyValue kv = new KeyValue(schema.getName(), String.valueOf(dataSchema.getExample()), schema.getDescription()); if (schemaInfo != null) {
Schema schemaInfo = infoMap.get(schema.getName()); if (schemaInfo instanceof BinarySchema) {
if (schemaInfo != null) { kv.setType("file");
if (schemaInfo instanceof BinarySchema) { }
kv.setType("file");
} }
} if (body != null) {
if (body != null) { if (body.getKvs() == null) {
if (body.getKvs() == null) { body.setKvs(new ArrayList<>());
body.setKvs(new ArrayList<>()); }
body.getKvs().add(kv);
} }
body.getKvs().add(kv);
} }
} }
} }

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;