diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger3Parser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger3Parser.java index a893f4498c..c1a88ddbcd 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger3Parser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger3Parser.java @@ -109,32 +109,30 @@ public class Swagger3Parser extends SwaggerAbstractParser { } } // 设置 query 参数 - StringBuilder pathBuilder = new StringBuilder(); - pathBuilder.append(request.getSwaggerUrl()); - if (!request.getSwaggerUrl().contains("?")) { - pathBuilder.append("?"); - } if (!CollectionUtils.isEmpty(request.getArguments())) { + StringBuilder pathBuilder = new StringBuilder(); + pathBuilder.append(request.getSwaggerUrl()); + if (StringUtils.isNotBlank(request.getSwaggerUrl()) && !request.getSwaggerUrl().contains("?")) { + pathBuilder.append("?"); + } for (KeyValue keyValue : request.getArguments()) { if (StringUtils.isNotBlank(keyValue.getName())) { AuthorizationValue authorizationValue = new AuthorizationValue(); authorizationValue.setType("query"); authorizationValue.setKeyName(keyValue.getName()); try { - authorizationValue.setValue(keyValue.isUrlEncode() ? URLEncoder.encode(keyValue.getValue(), StandardCharsets.UTF_8) : keyValue.getValue()); + authorizationValue.setValue(URLEncoder.encode(keyValue.getValue(), StandardCharsets.UTF_8)); } catch (Exception e) { LogUtil.info("swagger3 url encode error: " + e); } pathBuilder.append(keyValue.getName()).append("=").append(authorizationValue.getValue()).append("&"); - auths.add(authorizationValue); } } + request.setSwaggerUrl(pathBuilder.substring(0, pathBuilder.length() - 1)); } - request.setSwaggerUrl(pathBuilder.substring(0, pathBuilder.length() - 1)); return CollectionUtils.size(auths) == 0 ? null : auths; } - private List parseRequests(OpenAPI openAPI, ApiTestImportRequest importRequest) { Paths paths = openAPI.getPaths(); diff --git a/framework/sdk-parent/frontend/src/components/environment/ApiEnvironmentConfig.vue b/framework/sdk-parent/frontend/src/components/environment/ApiEnvironmentConfig.vue index a1cd006fd5..2ddb9f1eb3 100644 --- a/framework/sdk-parent/frontend/src/components/environment/ApiEnvironmentConfig.vue +++ b/framework/sdk-parent/frontend/src/components/environment/ApiEnvironmentConfig.vue @@ -8,7 +8,7 @@ :data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment" :env-add-permission="ENV_CREATE" :delete-fuc="openDelEnv" @itemSelected="environmentSelected" ref="environmentItems"/> - @@ -164,9 +164,7 @@ export default { } }) this.$refs.environmentEdit._save(newEnvironment); - this.environments.unshift(newEnvironment); - this.$refs.environmentItems.itemSelected(this.environments.length - 1, newEnvironment); - this.refresh(); + this.getEnvironments(); }, validateEnvironment(environment) { if (!this.$refs.environmentEdit.validate()) { @@ -199,6 +197,7 @@ export default { if (this.projectId) { this.result = getEnvironmentByProjectId(this.projectId).then(response => { this.environments = response.data; + this.currentEnvironment.id = null; if (this.environments.length > 0) { if (this.selectEnvironmentId) { const index = this.environments.findIndex(e => e.id === this.selectEnvironmentId);