From fba6283ca9aa339dc50fa96d22aa10051bcf4f53 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Wed, 1 Feb 2023 17:36:55 +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=8D=E9=83=A8=E5=88=86=E6=8E=A5=E5=8F=A3=E5=AF=BC?= =?UTF-8?q?=E5=87=BAswagger=E6=96=87=E4=BB=B6=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1022261 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001022261 --- .../api/parse/api/Swagger3Parser.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) 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;