From 3c95beec2ddb38f9e69ff4a64f364de43cb85b5b Mon Sep 17 00:00:00 2001 From: wenyann Date: Mon, 24 May 2021 18:35:49 +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=E6=B5=8B=E8=AF=95-=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=9A=E4=B9=89-=E6=8E=A5=E5=8F=A3=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=AF=BC=E5=87=BAswagger3.0=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiDefinitionService.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 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 303f711540..81d5fad1a6 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -991,17 +991,19 @@ public class ApiDefinitionService { ((MsApiExportResult) apiExportResult).setProtocol(request.getProtocol()); ((MsApiExportResult) apiExportResult).setProjectId(request.getProjectId()); ((MsApiExportResult) apiExportResult).setVersion(System.getenv("MS_VERSION")); + if (CollectionUtils.isNotEmpty(((MsApiExportResult) apiExportResult).getData())) { + List names = ((MsApiExportResult) apiExportResult).getData().stream().map(ApiDefinitionWithBLOBs::getName).collect(Collectors.toList()); + request.setName(String.join(",", names)); + List ids = ((MsApiExportResult) apiExportResult).getData().stream().map(ApiDefinitionWithBLOBs::getId).collect(Collectors.toList()); + request.setId(JSON.toJSONString(ids)); + } } else { // 导出为 Swagger 格式 Swagger3Parser swagger3Parser = new Swagger3Parser(); System.out.println(apiDefinitionMapper.selectByExampleWithBLOBs(example)); apiExportResult = swagger3Parser.swagger3Export(apiDefinitionMapper.selectByExampleWithBLOBs(example)); + } - if (CollectionUtils.isNotEmpty(((MsApiExportResult) apiExportResult).getData())) { - List names = ((MsApiExportResult) apiExportResult).getData().stream().map(ApiDefinitionWithBLOBs::getName).collect(Collectors.toList()); - request.setName(String.join(",", names)); - List ids = ((MsApiExportResult) apiExportResult).getData().stream().map(ApiDefinitionWithBLOBs::getId).collect(Collectors.toList()); - request.setId(JSON.toJSONString(ids)); - } + return apiExportResult; }