From 7e1c31e4298782e07ab6cbcbc8691d5f06d525a3 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 6 Sep 2022 11:09:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AF=BC=E5=85=A5swagger=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E4=B8=8D=E5=A2=9E=E5=8A=A0case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 --- .../io/metersphere/api/service/ApiDefinitionService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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);