diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 38539a47d6..de65b76751 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -932,7 +932,10 @@ public class ApiDefinitionService { } else { apiDefinition.setVersionId(apiTestImportRequest.getDefaultVersion()); } - caseList = setRequestAndAddNewCase(apiDefinition, caseList, true); + + boolean newCreate = !StringUtils.equals(ApiImportPlatform.Swagger2.name(), apiDefinitionImportParamDTO.getApiTestImportRequest().getPlatform()) + && !StringUtils.isNotBlank(apiDefinitionImportParamDTO.getApiTestImportRequest().getSwaggerUrl()); + caseList = setRequestAndAddNewCase(apiDefinition, caseList, newCreate); reSetImportMocksApiId(mocks, originId, apiDefinition.getId(), apiDefinition.getNum()); batchMapper.insert(apiDefinition); List apiTestCaseDTOS = importCase(apiDefinition, apiTestCaseMapper, caseList); @@ -1067,7 +1070,9 @@ public class ApiDefinitionService { } reSetImportMocksApiId(mocks, originId, apiDefinition.getId(), apiDefinition.getNum()); - caseList = setRequestAndAddNewCase(apiDefinition, caseList, true); + boolean newCreate = !StringUtils.equals(ApiImportPlatform.Swagger2.name(), apiDefinitionImportParamDTO.getApiTestImportRequest().getPlatform()) + && !StringUtils.isNotBlank(apiDefinitionImportParamDTO.getApiTestImportRequest().getSwaggerUrl()); + caseList = setRequestAndAddNewCase(apiDefinition, caseList, newCreate); batchMapper.insert(apiDefinition); ApiDefinitionResult apiDefinitionResult = getApiDefinitionResult(apiDefinition, false); apiImportSendNoticeDTO.setApiDefinitionResult(apiDefinitionResult);