From e927b1e6acc4140f2beec696a4ec2ef0ac723c7c Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 5 Jan 2021 15:58:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20swagger=20=E5=90=8D=E7=A7=B0=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/metersphere/api/parse/Swagger2Parser.java | 4 +++- .../main/java/io/metersphere/api/parse/Swagger3Parser.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java b/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java index 8d78614dad..d61d9af101 100644 --- a/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java +++ b/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java @@ -97,8 +97,10 @@ public class Swagger2Parser extends ApiImportAbstractParser { String name = ""; if (StringUtils.isNotBlank(operation.getSummary())) { name = operation.getSummary(); - } else { + } else if (StringUtils.isNotBlank(operation.getOperationId())) { name = operation.getOperationId(); + } else { + name = path; } return buildApiDefinition(id, name, path, method); } diff --git a/backend/src/main/java/io/metersphere/api/parse/Swagger3Parser.java b/backend/src/main/java/io/metersphere/api/parse/Swagger3Parser.java index 3e8ab93dd9..92edcfddf1 100644 --- a/backend/src/main/java/io/metersphere/api/parse/Swagger3Parser.java +++ b/backend/src/main/java/io/metersphere/api/parse/Swagger3Parser.java @@ -129,8 +129,10 @@ public class Swagger3Parser extends ApiImportAbstractParser { String name = ""; if (StringUtils.isNotBlank(operation.getSummary())) { name = operation.getSummary(); - } else { + } else if (StringUtils.isNotBlank(operation.getOperationId())) { name = operation.getOperationId(); + } else { + name = path; } return buildApiDefinition(id, name, path, method); }