修复NPE问题

This commit is contained in:
tanghc
2019-11-21 14:10:46 +08:00
parent 95c577f2a5
commit 8d63d865f6

View File

@@ -35,6 +35,9 @@ public class SwaggerDocParser implements DocParser {
List<DocItem> docItems = new ArrayList<>(); List<DocItem> docItems = new ArrayList<>();
JSONObject paths = docRoot.getJSONObject("paths"); JSONObject paths = docRoot.getJSONObject("paths");
if (paths == null) {
paths = new JSONObject();
}
Set<String> pathNameSet = paths.keySet(); Set<String> pathNameSet = paths.keySet();
for (String apiPath : pathNameSet) { for (String apiPath : pathNameSet) {
JSONObject pathInfo = paths.getJSONObject(apiPath); JSONObject pathInfo = paths.getJSONObject(apiPath);