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

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

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