We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/** * 递归生成ModelAttr * 对$ref类型设置具体属性 */
private ModelAttr getAndPutModelAttr(Map<String, Map<String, Object>> swaggerMap, Map<String, ModelAttr> resMap, String modeName) { ModelAttr modeAttr; if ((modeAttr = resMap.get("#/definitions/" + modeName)) == null) { modeAttr = new ModelAttr(); resMap.put("#/definitions/" + modeName, modeAttr); } else if (modeAttr.isCompleted()) { return resMap.get("#/definitions/" + modeName); } Map<String, Object> modeProperties = (Map<String, Object>) swaggerMap.get(modeName).get("properties");
// 第1行 List required = Optional.ofNullable(((List)swaggerMap.get(modeName).get("required"))).orElse(new ArrayList<>());
if (modeProperties == null) { return null; } Iterator<Entry<String, Object>> mIt = modeProperties.entrySet().iterator(); List<ModelAttr> attrList = new ArrayList<>(); //解析属性 while (mIt.hasNext()) { Entry<String, Object> mEntry = mIt.next(); Map<String, Object> attrInfoMap = (Map<String, Object>) mEntry.getValue(); ModelAttr child = new ModelAttr(); child.setName(mEntry.getKey()); child.setType((String) attrInfoMap.get("type")); if (attrInfoMap.get("format") != null) { child.setType(child.getType() + "(" + attrInfoMap.get("format") + ")"); } child.setType(StringUtils.defaultIfBlank(child.getType(), "object"));
// 第2行 child.setRequire(required.contains(child.getName()) ? true : false);
Object ref = attrInfoMap.get("$ref"); Object items = attrInfoMap.get("items"); if (ref != null || (items != null && (ref = ((Map) items).get("$ref")) != null)) { String refName = ref.toString(); //截取 #/definitions/ 后面的 String clsName = refName.substring(14); modeAttr.setCompleted(true); ModelAttr refModel = getAndPutModelAttr(swaggerMap, resMap, clsName); if (refModel != null) { child.setProperties(refModel.getProperties()); } child.setType(child.getType() + ":" + clsName); } child.setDescription((String) attrInfoMap.get("description")); attrList.add(child); } Object title = swaggerMap.get(modeName).get("title"); Object description = swaggerMap.get(modeName).get("description"); modeAttr.setClassName(title == null ? "" : title.toString()); modeAttr.setDescription(description == null ? "" : description.toString()); modeAttr.setProperties(attrList); return modeAttr; }
The text was updated successfully, but these errors were encountered:
思密达提交pr了嘛 required.contains 不友好,换成map?
Sorry, something went wrong.
No branches or pull requests
/**
* 递归生成ModelAttr
* 对$ref类型设置具体属性
*/
// 第1行
List required = Optional.ofNullable(((List)swaggerMap.get(modeName).get("required"))).orElse(new ArrayList<>());
// 第2行
child.setRequire(required.contains(child.getName()) ? true : false);
The text was updated successfully, but these errors were encountered: