fix: swagger2导入报空指针

This commit is contained in:
chenjianxing 2022-01-13 15:15:59 +08:00 committed by jianxing
parent a44605376b
commit 32c06ce462
1 changed files with 5 additions and 6 deletions

View File

@ -293,6 +293,7 @@ public class Swagger2Parser extends SwaggerAbstractParser {
HashSet<String> refSet = new HashSet<>(); HashSet<String> refSet = new HashSet<>();
Model model = getRefModelType(schema, refSet); Model model = getRefModelType(schema, refSet);
item.setType("object"); item.setType("object");
if (model != null)
item.setProperties(parseSchemaProperties(model.getProperties(), refSet)); item.setProperties(parseSchemaProperties(model.getProperties(), refSet));
} else if (schema instanceof ArrayModel) { } else if (schema instanceof ArrayModel) {
//模型数组 //模型数组
@ -301,11 +302,9 @@ public class Swagger2Parser extends SwaggerAbstractParser {
handleArrayItemProperties(item, arrayModel.getItems(), refSet); handleArrayItemProperties(item, arrayModel.getItems(), refSet);
} else if (schema instanceof ModelImpl) { } else if (schema instanceof ModelImpl) {
ModelImpl model = (ModelImpl) schema; ModelImpl model = (ModelImpl) schema;
Map<String, Property> properties = model.getProperties();
if (model != null) {
item.setType("object"); item.setType("object");
item.setProperties(parseSchemaProperties(properties, new HashSet<>())); if (model != null)
} item.setProperties(parseSchemaProperties(model.getProperties(), new HashSet<>()));
} }
if (schema.getExample() != null) { if (schema.getExample() != null) {
item.getMock().put("mock", schema.getExample()); item.getMock().put("mock", schema.getExample());