|
|
@ -18,6 +18,7 @@ import java.util.Collections; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.Objects; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -170,7 +171,7 @@ public class SwaggerDocParser implements DocParser { |
|
|
|
List<DocParameter> respParameterList = Collections.emptyList(); |
|
|
|
List<DocParameter> respParameterList = Collections.emptyList(); |
|
|
|
if (refInfo != null) { |
|
|
|
if (refInfo != null) { |
|
|
|
String responseRef = refInfo.ref; |
|
|
|
String responseRef = refInfo.ref; |
|
|
|
respParameterList = this.buildDocParameters(responseRef, docRoot); |
|
|
|
respParameterList = this.buildDocParameters(responseRef, docRoot, true); |
|
|
|
// 如果返回数组
|
|
|
|
// 如果返回数组
|
|
|
|
if (refInfo.isArray) { |
|
|
|
if (refInfo.isArray) { |
|
|
|
DocParameter docParameter = new DocParameter(); |
|
|
|
DocParameter docParameter = new DocParameter(); |
|
|
@ -183,7 +184,7 @@ public class SwaggerDocParser implements DocParser { |
|
|
|
return respParameterList; |
|
|
|
return respParameterList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected List<DocParameter> buildDocParameters(String ref, JSONObject docRoot) { |
|
|
|
protected List<DocParameter> buildDocParameters(String ref, JSONObject docRoot, boolean doSubRef) { |
|
|
|
JSONObject responseObject = docRoot.getJSONObject("definitions").getJSONObject(ref); |
|
|
|
JSONObject responseObject = docRoot.getJSONObject("definitions").getJSONObject(ref); |
|
|
|
JSONObject properties = responseObject.getJSONObject("properties"); |
|
|
|
JSONObject properties = responseObject.getJSONObject("properties"); |
|
|
|
Set<String> fieldNames = properties.keySet(); |
|
|
|
Set<String> fieldNames = properties.keySet(); |
|
|
@ -200,8 +201,11 @@ public class SwaggerDocParser implements DocParser { |
|
|
|
docParameter.setName(fieldName); |
|
|
|
docParameter.setName(fieldName); |
|
|
|
docParameterList.add(docParameter); |
|
|
|
docParameterList.add(docParameter); |
|
|
|
RefInfo refInfo = this.getRefInfo(fieldInfo); |
|
|
|
RefInfo refInfo = this.getRefInfo(fieldInfo); |
|
|
|
if (refInfo != null) { |
|
|
|
if (refInfo != null && doSubRef) { |
|
|
|
List<DocParameter> refs = buildDocParameters(refInfo.ref, docRoot); |
|
|
|
// 如果是树状菜单的话,这里可能触发死循环
|
|
|
|
|
|
|
|
String subRef = refInfo.ref; |
|
|
|
|
|
|
|
boolean nextDoRef = !Objects.equals(ref, subRef); |
|
|
|
|
|
|
|
List<DocParameter> refs = buildDocParameters(subRef, docRoot, nextDoRef); |
|
|
|
docParameter.setRefs(refs); |
|
|
|
docParameter.setRefs(refs); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|