From 090e877a475050312700351f9dfee23e48538674 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Thu, 1 Dec 2022 20:48:58 +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=8Dswagger=E6=96=87=E4=BB=B6=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1019960--user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001019960 --- .../java/io/metersphere/api/parse/api/Swagger2Parser.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger2Parser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger2Parser.java index c9c1a03392..ea7db5d677 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger2Parser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger2Parser.java @@ -51,7 +51,7 @@ public class Swagger2Parser extends SwaggerAbstractParser { sourceStr = getApiTestStr(source); // 导入的二进制文件转换为 String //注:有一特殊情况,swagger2.0 文件里如果在response的parameter参数下的properties的参数里存在 required 为string类型, //swagger2.0不会导入,需替换一下 - sourceStr = replaceStr(sourceStr); + sourceStr = replaceStr(sourceStr); JSONObject jsonObject = JSONUtil.parseObject(sourceStr); if (jsonObject.opt("swagger") == null || jsonObject.opt("swagger") == "null" || jsonObject.opt("swagger") == StringUtils.SPACE) { @@ -73,7 +73,7 @@ public class Swagger2Parser extends SwaggerAbstractParser { } public static String replaceStr(String sourceStr) { - return sourceStr.replaceAll("\"required\": \".*\"", "\"required\": []"); + return sourceStr.replaceAll("\"required\": \"(.*?)\"", "\"required\": []"); } // 鉴权设置