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 4454adfdfe..4e2a8ec128 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 @@ -606,7 +606,7 @@ public class Swagger3Parser extends SwaggerAbstractParser { } }*/ //直接导出完整路径 - if (apiDefinition.getModulePath() != null) { + if (StringUtils.isNotBlank(apiDefinition.getModulePath())) { String[] split = new String[0]; String modulePath = apiDefinition.getModulePath(); String substring = modulePath.substring(0, 1); @@ -620,6 +620,8 @@ public class Swagger3Parser extends SwaggerAbstractParser { split = new String[]{modulePath}; } swaggerApiInfo.setTags(Arrays.asList(split)); + } else { + swaggerApiInfo.setTags(new ArrayList<>()); } // 设置请求体 @@ -1018,6 +1020,9 @@ public class Swagger3Parser extends SwaggerAbstractParser { } private String getModulePath(List tagTree, StringBuilder modulePath) { + if (CollectionUtils.isEmpty(tagTree)) { + return "/未规划接口"; + } for (String s : tagTree) { if (s.contains("/")) { String[] split = s.split("/"); diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java index 3e190617f8..0ecbf6c9bd 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioModuleService.java @@ -902,12 +902,15 @@ public class ApiScenarioModuleService extends NodeTreeService moduleList = pidChildrenMap.get(parentModule.getId()); - List collect1 = moduleList.stream().filter(t -> t.getName().equals(tagTree[finalI])).collect(Collectors.toList()); - if (collect1.isEmpty()) { + List filterModuleList = null; + if (!CollectionUtils.isEmpty(moduleList)) { + filterModuleList = moduleList.stream().filter(t -> t.getName().equals(tagTree[finalI])).collect(Collectors.toList()); + } + if (CollectionUtils.isEmpty(filterModuleList)) { return createModule(tagTree, i, parentModule, moduleMap, pidChildrenMap, idPathMap); } else { - returnModule = collect1.get(0); - parentModule = collect1.get(0); + returnModule = filterModuleList.get(0); + parentModule = filterModuleList.get(0); } } return returnModule; diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml index 1d7ebd3678..76989bf38f 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml @@ -655,7 +655,7 @@ inner join project on api_test_case.project_id = project.id inner JOIN api_definition a ON api_test_case.api_definition_id = a.id - and a.latest is not null + and a.latest = 1