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); }