refactor: postman导入优化

This commit is contained in:
chenjianxing 2021-01-06 15:13:21 +08:00
parent cc3006b9a1
commit f9f5ff86bd
2 changed files with 14 additions and 2 deletions

View File

@ -65,10 +65,12 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
protected ApiModule getSelectModule(String moduleId) {
apiModuleService = CommonBeanFactory.getBean(ApiModuleService.class);
if (StringUtils.isNotBlank(moduleId)) {
if (StringUtils.isNotBlank(moduleId) && !StringUtils.equals("root", moduleId)) {
ApiModule module = new ApiModule();
ApiModuleDTO moduleDTO = apiModuleService.getNode(moduleId);
BeanUtils.copyBean(module, moduleDTO);
if (moduleDTO != null) {
BeanUtils.copyBean(module, moduleDTO);
}
return module;
}
return null;

View File

@ -61,6 +61,16 @@ public class PostmanParser extends ApiImportAbstractParser {
MsHTTPSamplerProxy request = buildRequest(requestItem.getName(), url.getRaw(), requestDesc.getMethod());
ApiDefinitionResult apiDefinition =
buildApiDefinition(request.getId(), requestItem.getName(), url.getRaw(), requestDesc.getMethod());
if (StringUtils.isNotBlank(request.getPath())) {
String path = request.getPath().split("\\?")[0];
path = path.replace("{{", "${");
path = path.replace("}}", "}");
request.setPath(path);
apiDefinition.setPath(path);
} else {
request.setPath("/");
apiDefinition.setPath("/");
}
parseBody(request.getBody(), requestDesc);
request.setArguments(parseKeyValue(url.getQuery()));
request.setHeaders(parseKeyValue(requestDesc.getHeader()));