diff --git a/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger3Parser.java b/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger3Parser.java index a55a951ba7..3e75440dd8 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger3Parser.java +++ b/api-test/backend/src/main/java/io/metersphere/api/parse/api/Swagger3Parser.java @@ -998,17 +998,19 @@ public class Swagger3Parser extends SwaggerAbstractParser { // 返回code JSONArray statusCode = response.optJSONArray("statusCode"); - for (int i = 0; i < statusCode.length(); i++) { - JSONObject statusCodeInfo = new JSONObject(); - statusCodeInfo.put("headers", headers); - statusCodeInfo.put("content", buildContent(response)); - statusCodeInfo.put("description", StringUtils.EMPTY); - JSONObject jsonObject = statusCode.getJSONObject(i); - if (jsonObject.optString("value") != null) { - statusCodeInfo.put("description", jsonObject.optString("value")); - } - if (jsonObject.optString("name") != null) { - responseBody.put(jsonObject.optString("name"), statusCodeInfo); + if (statusCode != null) { + for (int i = 0; i < statusCode.length(); i++) { + JSONObject statusCodeInfo = new JSONObject(); + statusCodeInfo.put("headers", headers); + statusCodeInfo.put("content", buildContent(response)); + statusCodeInfo.put("description", StringUtils.EMPTY); + JSONObject jsonObject = statusCode.getJSONObject(i); + if (jsonObject.optString("value") != null) { + statusCodeInfo.put("description", jsonObject.optString("value")); + } + if (jsonObject.optString("name") != null) { + responseBody.put(jsonObject.optString("name"), statusCodeInfo); + } } } return responseBody;