提交 7ec72c52 authored 作者: mry's avatar mry

fix(web): 修复了返回值信息不完整的问题

上级 37c918b2
......@@ -124,46 +124,55 @@ public class SwaggerController {
if (schema.containsKey("$ref")) {
ref = schema.getString("$ref");
}
ResponseVo resp = new ResponseVo();
if ("array".equalsIgnoreCase(schemaType)) {
JSONObject items = schema.getJSONObject("items");
if (items.containsKey("$ref")) {
ref = schema.getString("$ref");
resp.setType(schemaType);
} else {
ResponseVo resp = new ResponseVo();
resp.setName("");
resp.setType(items.getString("type"));
respParameters.add(resp);
List<ResponseVo> childRespList = new ArrayList<>();
ResponseVo childResp = new ResponseVo();
childResp.setName("");
childResp.setType(items.getString("type"));
childRespList.add(childResp);
resp.setChildResp(childRespList);
}
} else {
resp.setType(StringUtils.isBlank(schemaType) ? "object" : schemaType);
}
if (StringUtils.isNotBlank(ref)) {
String def = ref.substring(14);
JSONObject defJson = refMap.get(def);
JSONObject properties = defJson.getJSONObject("properties");
Set<String> respKeys = properties.keySet();
List<ResponseVo> childRespList = new ArrayList<>();
for (String key : respKeys) {
JSONObject respMap = properties.getJSONObject(key);
ResponseVo resp = new ResponseVo();
resp.setName(key);
resp.setDescription(respMap.getString("description"));
ResponseVo childResp = new ResponseVo();
childResp.setName(key);
childResp.setDescription(respMap.getString("description"));
String respType = respMap.getString("type");
resp.setType(StringUtils.isBlank(respType) ? "object" : respType);
resp.setRequired(respMap.getBooleanValue("required"));
childResp.setType(StringUtils.isBlank(respType) ? "object" : respType);
childResp.setRequired(respMap.getBooleanValue("required"));
if (respMap.containsKey("$ref")) {
String childDef = getRef(respMap);
JSONObject childDefJson = refMap.get(childDef);
JSONObject childProperties = childDefJson.getJSONObject("properties");
getRef(refMap, childProperties, resp, childDef, childDefJson);
getRef(refMap, childProperties, childResp, childDef, childDefJson);
} else if ("array".equalsIgnoreCase(respType)) {
JSONObject items = respMap.getJSONObject("items");
if (items.containsKey("$ref")) {
String itemDef = getRef(items);
JSONObject itemDefJson = refMap.get(itemDef);
JSONObject childProperties = itemDefJson.getJSONObject("properties");
getRef(refMap, childProperties, resp, itemDef, itemDefJson);
getRef(refMap, childProperties, childResp, itemDef, itemDefJson);
}
}
respParameters.add(resp);
childRespList.add(childResp);
resp.setChildResp(childRespList);
}
respParameters.add(resp);
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论