fix: postman导入报错

This commit is contained in:
chenjianxing 2021-07-23 14:13:43 +08:00 committed by jianxing
parent 9760b70762
commit 1182aa78bf
2 changed files with 9 additions and 2 deletions

View File

@ -54,6 +54,9 @@ public abstract class PostmanAbstractParserParser<T> extends ApiImportAbstractPa
* @return * @return
*/ */
public String parseVariable(String value) { public String parseVariable(String value) {
if (StringUtils.isBlank(value)) {
return value;
}
try { try {
Pattern pattern = Pattern.compile("(\\{\\{(.*?)\\}\\})"); Pattern pattern = Pattern.compile("(\\{\\{(.*?)\\}\\})");
Matcher matcher = pattern.matcher(value); Matcher matcher = pattern.matcher(value);
@ -107,7 +110,11 @@ public abstract class PostmanAbstractParserParser<T> extends ApiImportAbstractPa
String k = parseVariable(item.getKey()); String k = parseVariable(item.getKey());
String v = parseVariable(item.getValue()); String v = parseVariable(item.getValue());
String desc = parseVariable(item.getDescription()); String desc = parseVariable(item.getDescription());
keyValues.add(new KeyValue(k, v, desc, item.getContentType())); KeyValue keyValue = new KeyValue(k, v, desc, item.getContentType());
if (StringUtils.isNotBlank(item.getType()) && StringUtils.equals("file", item.getType())) {
keyValue.setType("file");
}
keyValues.add(keyValue);
}); });
return keyValues; return keyValues;
} }

View File

@ -798,6 +798,7 @@ public class ApiDefinitionService {
if (i % 300 == 0) { if (i % 300 == 0) {
sqlSession.flushStatements(); sqlSession.flushStatements();
} }
sqlSession.flushStatements();
} }
//判断EsbData是否需要存储 //判断EsbData是否需要存储
if (apiImport.getEsbApiParamsMap() != null && apiImport.getEsbApiParamsMap().size() > 0) { if (apiImport.getEsbApiParamsMap() != null && apiImport.getEsbApiParamsMap().size() > 0) {
@ -819,7 +820,6 @@ public class ApiDefinitionService {
if (!CollectionUtils.isEmpty(apiImport.getCases())) { if (!CollectionUtils.isEmpty(apiImport.getCases())) {
importMsCase(apiImport, sqlSession, apiTestCaseMapper); importMsCase(apiImport, sqlSession, apiTestCaseMapper);
} }
sqlSession.flushStatements();
} }