fix: swagger2.0 导入失败

This commit is contained in:
chenjianxing 2021-01-08 14:40:07 +08:00
parent 5cbaeb06c4
commit aa53e696cc
1 changed files with 7 additions and 3 deletions

View File

@ -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<String> 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 "";
}