fix(接口测试): 解决接口定义导出swagger失败

--bug=1011524
--user=郭雨琦
【接口测试】-接口定义中导出全部数据为swagger格式失败
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001011524
This commit is contained in:
guoyuqi 2022-03-22 19:10:36 +08:00 committed by fit2-zhao
parent 85aa8ab18c
commit 93019cafe2

View File

@ -947,7 +947,9 @@ public class Swagger3Parser extends SwaggerAbstractParser {
} else if (bodyType.equalsIgnoreCase("RAW")) {
bodyInfo = new JSONObject();
((JSONObject) bodyInfo).put("type", "string");
((JSONObject) bodyInfo).put("example", body.get("raw").toString());
if (body != null && body.get("raw") != null) {
((JSONObject) bodyInfo).put("example", body.get("raw").toString());
}
} else if (bodyType.equalsIgnoreCase("XML")) {
String xmlText = body.getString("raw");
JSONObject xmlToJson = XMLUtils.XmlToJson(xmlText);