bugfix-NPE异常

例如:当 ref = ApiResult«Void» 时, definitions的结构如下

         	"definitions": {
        		"ApiResult«Void»": {
        			"type": "object",
        			"title": "ApiResult«Void»"
        		}
        	}
pull/2/head
梁来宾 5 years ago
parent f66e2f8891
commit 7f83dbe5b0
  1. 5
      sop-website/src/main/java/com/gitee/sop/websiteserver/manager/SwaggerDocParser.java

@ -208,8 +208,11 @@ public class SwaggerDocParser implements DocParser {
protected List<DocParameter> buildDocParameters(String ref, JSONObject docRoot, boolean doSubRef) { 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();
List<DocParameter> docParameterList = new ArrayList<>(); List<DocParameter> docParameterList = new ArrayList<>();
if (properties == null) {
return docParameterList;
}
Set<String> fieldNames = properties.keySet();
for (String fieldName : fieldNames) { for (String fieldName : fieldNames) {
/* /*
{ {

Loading…
Cancel
Save