diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3ParserApiDefinition.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3ParserApiDefinition.java index b1da06602b..eda2e67b2f 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3ParserApiDefinition.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3ParserApiDefinition.java @@ -121,11 +121,17 @@ public class Swagger3ParserApiDefinition extends HttpApiDefinitionImportAbstract // 设置 headers if (StringUtils.isNotBlank(request.getSwaggerToken())) { - AuthorizationValue authorizationValue = new AuthorizationValue(); - authorizationValue.setType(HEADER); - authorizationValue.setKeyName("token"); - authorizationValue.setValue(request.getSwaggerToken()); - auths.add(authorizationValue); + String[] tokenRows = StringUtils.split(request.getSwaggerToken(), StringUtils.LF); + for (String row : tokenRows) { + String[] tokenArr = StringUtils.split(row, ":"); + if (tokenArr.length == 2) { + AuthorizationValue authorizationValue = new AuthorizationValue(); + authorizationValue.setType(HEADER); + authorizationValue.setKeyName(tokenArr[0]); + authorizationValue.setValue(tokenArr[1]); + auths.add(authorizationValue); + } + } } return CollectionUtils.size(auths) == 0 ? null : auths; diff --git a/frontend/src/views/api-test/management/components/import.vue b/frontend/src/views/api-test/management/components/import.vue index d125215c60..b69619ba59 100644 --- a/frontend/src/views/api-test/management/components/import.vue +++ b/frontend/src/views/api-test/management/components/import.vue @@ -158,7 +158,12 @@ > - +
@@ -228,7 +233,12 @@ > - +