From aa53e696cc59602238504672fb0febc08983bd3f Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 8 Jan 2021 14:40:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20swagger2.0=20=E5=AF=BC=E5=85=A5=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/metersphere/api/parse/Swagger2Parser.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java b/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java index b080aa2e23..aa20d97e7a 100644 --- a/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java +++ b/backend/src/main/java/io/metersphere/api/parse/Swagger2Parser.java @@ -220,16 +220,20 @@ public class Swagger2Parser extends SwaggerAbstractParser { //模型数组 ArrayModel arrayModel = (ArrayModel) schema; Property items = arrayModel.getItems(); + JSONArray propertyList = new JSONArray(); if (items instanceof RefProperty) { RefProperty refProperty = (RefProperty) items; String simpleRef = refProperty.getSimpleRef(); HashSet refSet = new HashSet<>(); refSet.add(simpleRef); Model model = definitions.get(simpleRef); - JSONArray propertyList = new JSONArray(); - propertyList.add(getBodyParameters(model.getProperties(), refSet)); - return propertyList.toString(); + if (model != null) { + propertyList.add(getBodyParameters(model.getProperties(), refSet)); + } else { + propertyList.add(new JSONObject()); + } } + return propertyList.toString(); } return ""; }