From 32c06ce462d96b045593c2b19aae1aa44d3e7ec7 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Thu, 13 Jan 2022 15:15:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20swagger2=E5=AF=BC=E5=85=A5=E6=8A=A5?= =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/parse/Swagger2Parser.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger2Parser.java b/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger2Parser.java index 716a0faada..32352ed013 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger2Parser.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger2Parser.java @@ -293,7 +293,8 @@ public class Swagger2Parser extends SwaggerAbstractParser { HashSet refSet = new HashSet<>(); Model model = getRefModelType(schema, refSet); item.setType("object"); - item.setProperties(parseSchemaProperties(model.getProperties(), refSet)); + if (model != null) + item.setProperties(parseSchemaProperties(model.getProperties(), refSet)); } else if (schema instanceof ArrayModel) { //模型数组 ArrayModel arrayModel = (ArrayModel) schema; @@ -301,11 +302,9 @@ public class Swagger2Parser extends SwaggerAbstractParser { handleArrayItemProperties(item, arrayModel.getItems(), refSet); } else if (schema instanceof ModelImpl) { ModelImpl model = (ModelImpl) schema; - Map properties = model.getProperties(); - if (model != null) { - item.setType("object"); - item.setProperties(parseSchemaProperties(properties, new HashSet<>())); - } + item.setType("object"); + if (model != null) + item.setProperties(parseSchemaProperties(model.getProperties(), new HashSet<>())); } if (schema.getExample() != null) { item.getMock().put("mock", schema.getExample());