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; ArrayModel arrayModel = (ArrayModel) schema;
Property items = arrayModel.getItems(); Property items = arrayModel.getItems();
JSONArray propertyList = new JSONArray();
if (items instanceof RefProperty) { if (items instanceof RefProperty) {
RefProperty refProperty = (RefProperty) items; RefProperty refProperty = (RefProperty) items;
String simpleRef = refProperty.getSimpleRef(); String simpleRef = refProperty.getSimpleRef();
HashSet<String> refSet = new HashSet<>(); HashSet<String> refSet = new HashSet<>();
refSet.add(simpleRef); refSet.add(simpleRef);
Model model = definitions.get(simpleRef); Model model = definitions.get(simpleRef);
JSONArray propertyList = new JSONArray(); if (model != null) {
propertyList.add(getBodyParameters(model.getProperties(), refSet)); propertyList.add(getBodyParameters(model.getProperties(), refSet));
return propertyList.toString(); } else {
propertyList.add(new JSONObject());
}
} }
return propertyList.toString();
} }
return ""; return "";
} }