From e895f6ee8b76820d81df2d70e3b9402da2b2d3c5 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 18 Apr 2024 09:47:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E5=AF=BC=E5=85=A5=E6=9C=AA?= =?UTF-8?q?=E5=AF=BC=E5=85=A5query=E5=80=BC=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1039645 --user=王孝刚 【接口测试】接口定义-导入swagger文件中query参数值未导入 https://www.tapd.cn/55049933/s/1500400 --- .../metersphere/api/parser/api/Swagger3Parser.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java b/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java index 77cd63ef82..72506c3151 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/parser/api/Swagger3Parser.java @@ -434,6 +434,9 @@ public class Swagger3Parser implements ImportParser { queryParam.setMinLength(queryParameter.getSchema().getMinLength()); queryParam.setMaxLength(queryParameter.getSchema().getMaxLength()); } + if (queryParameter.getExample() != null) { + queryParam.setValue(getDefaultObjectValue(queryParameter.getExample())); + } arguments.add(queryParam); } @@ -445,6 +448,9 @@ public class Swagger3Parser implements ImportParser { if (cookieParameter.getSchema() != null) { headerParams.setValue(getDefaultObjectValue(cookieParameter.getSchema().getExample())); } + if (cookieParameter.getExample() != null) { + headerParams.setValue(getDefaultObjectValue(cookieParameter.getExample())); + } headers.add(headerParams); } @@ -455,6 +461,9 @@ public class Swagger3Parser implements ImportParser { if (headerParameter.getSchema() != null) { headerParams.setValue(getDefaultObjectValue(headerParameter.getSchema().getExample())); } + if (headerParameter.getExample() != null) { + headerParams.setValue(getDefaultObjectValue(headerParameter.getExample())); + } headers.add(headerParams); } @@ -470,6 +479,9 @@ public class Swagger3Parser implements ImportParser { restParam.setMinLength(parameter.getSchema().getMinLength()); restParam.setMaxLength(parameter.getSchema().getMaxLength()); } + if (parameter.getExample() != null) { + restParam.setValue(getDefaultObjectValue(parameter.getExample())); + } rest.add(restParam); }