From 5400338962952268cb2a0091bcc8bee84f268983 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Tue, 24 Sep 2024 16:18:04 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20cURL=E5=AF=BC=E5=85=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/debug/ApiDebugController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/debug/ApiDebugController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/debug/ApiDebugController.java index a2318baa22..455bc72fb6 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/controller/debug/ApiDebugController.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/debug/ApiDebugController.java @@ -14,6 +14,7 @@ import io.metersphere.project.service.FileModuleService; import io.metersphere.sdk.constants.DefaultRepositoryDir; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.dto.api.task.TaskRequestDTO; +import io.metersphere.sdk.util.JSON; import io.metersphere.system.dto.sdk.BaseTreeNode; import io.metersphere.system.file.annotation.FileLimit; import io.metersphere.system.log.annotation.Log; @@ -30,6 +31,8 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.util.List; +import java.util.Map; +import java.util.Optional; /** * @author : jianxing @@ -132,6 +135,12 @@ public class ApiDebugController { @RequiresPermissions(value = {PermissionConstants.PROJECT_API_DEBUG_READ, PermissionConstants.PROJECT_API_SCENARIO_ADD}, logical = Logical.OR) public CurlEntity importCurl(@RequestBody ApiImportCurlRequest request) { CurlEntity parse = CurlParserUtil.parse(request.getCurl()); + Optional.ofNullable(parse.getBody()).ifPresent(body -> { + if (parse.getMethod() == CurlEntity.Method.GET) { + Map map = JSON.parseMap(JSON.toFormatJSONString(body)); + parse.getQueryParams().putAll(map); + } + }); return parse; }