fix(接口测试): 修复部分接口导出swagger文件报错问题

--bug=1022261 --user=郭雨琦
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001022261
This commit is contained in:
guoyuqi 2023-02-01 17:36:55 +08:00 committed by xiaomeinvG
parent 8118fb9518
commit fba6283ca9
1 changed files with 13 additions and 11 deletions

View File

@ -998,17 +998,19 @@ public class Swagger3Parser extends SwaggerAbstractParser {
// 返回code // 返回code
JSONArray statusCode = response.optJSONArray("statusCode"); JSONArray statusCode = response.optJSONArray("statusCode");
for (int i = 0; i < statusCode.length(); i++) { if (statusCode != null) {
JSONObject statusCodeInfo = new JSONObject(); for (int i = 0; i < statusCode.length(); i++) {
statusCodeInfo.put("headers", headers); JSONObject statusCodeInfo = new JSONObject();
statusCodeInfo.put("content", buildContent(response)); statusCodeInfo.put("headers", headers);
statusCodeInfo.put("description", StringUtils.EMPTY); statusCodeInfo.put("content", buildContent(response));
JSONObject jsonObject = statusCode.getJSONObject(i); statusCodeInfo.put("description", StringUtils.EMPTY);
if (jsonObject.optString("value") != null) { JSONObject jsonObject = statusCode.getJSONObject(i);
statusCodeInfo.put("description", jsonObject.optString("value")); if (jsonObject.optString("value") != null) {
} statusCodeInfo.put("description", jsonObject.optString("value"));
if (jsonObject.optString("name") != null) { }
responseBody.put(jsonObject.optString("name"), statusCodeInfo); if (jsonObject.optString("name") != null) {
responseBody.put(jsonObject.optString("name"), statusCodeInfo);
}
} }
} }
return responseBody; return responseBody;