fix(接口测试): 修复swagger文件导入问题

--bug=1019960--user=郭雨琦
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001019960
This commit is contained in:
guoyuqi 2022-12-01 20:48:58 +08:00 committed by xiaomeinvG
parent 3ffe71a657
commit 090e877a47
1 changed files with 2 additions and 2 deletions

View File

@ -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\": []");
}
// 鉴权设置