You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by zh...@apache.org on 2022/06/03 02:23:41 UTC

[incubator-shenyu] branch master updated: [ISSUE #3447] NPE repair of admin module caused by spring MVC example synchronization

This is an automated email from the ASF dual-hosted git repository.

zhangzicheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 832619e58 [ISSUE #3447] NPE repair of admin module caused by spring MVC example synchronization
832619e58 is described below

commit 832619e58e92338b94c5c78a5011a61a84bef252
Author: renzhuyan <40...@qq.com>
AuthorDate: Thu Jun 2 21:23:35 2022 -0500

    [ISSUE #3447] NPE repair of admin module caused by spring MVC example synchronization
    
    * NPE repair of admin module caused by spring MVC example synchronization
    
    * fix
---
 .../shenyu/admin/service/manager/impl/SwaggerDocParser.java       | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java
index 8365eb76b..aaf3770ce 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java
@@ -56,7 +56,7 @@ public class SwaggerDocParser implements DocParser {
     @Override
     public DocInfo parseJson(final JSONObject docRoot) {
         final String basePath = docRoot.getString("basePath");
-        final String title = docRoot.getJSONObject("info").getString("title");
+        final String title = Optional.ofNullable(docRoot.getJSONObject("info")).map(jsonObject -> jsonObject.getString("title")).orElse(basePath);
         final List<DocItem> docItems = new ArrayList<>();
 
         JSONObject paths = docRoot.getJSONObject("paths");
@@ -154,7 +154,7 @@ public class SwaggerDocParser implements DocParser {
         }
         docItem.setModuleOrder(NumberUtils.toInt(docInfo.getString("module_order"), 0));
         docItem.setApiOrder(NumberUtils.toInt(docInfo.getString("api_order"), 0));
-        String moduleName = this.buildModuleName(docInfo, docRoot);
+        String moduleName = this.buildModuleName(docInfo, docRoot, basePath);
         docItem.setModule(moduleName);
         List<DocParameter> docParameterList = this.buildRequestParameterList(docInfo, docRoot);
         docItem.setRequestParameters(docParameterList);
@@ -164,8 +164,8 @@ public class SwaggerDocParser implements DocParser {
         return docItem;
     }
 
-    protected String buildModuleName(final JSONObject docInfo, final JSONObject docRoot) {
-        String title = docRoot.getJSONObject("info").getString("title");
+    protected String buildModuleName(final JSONObject docInfo, final JSONObject docRoot, final String basePath) {
+        final String title = Optional.ofNullable(docRoot.getJSONObject("info")).map(jsonObject -> jsonObject.getString("title")).orElse(basePath);
         JSONArray tags = docInfo.getJSONArray("tags");
         if (Objects.nonNull(tags) && tags.size() > 0) {
             return tags.getString(0);