eye-gu commented on code in PR #6339:
URL: https://github.com/apache/shenyu/pull/6339#discussion_r3253900504


##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/ApiServiceImpl.java:
##########
@@ -243,12 +243,14 @@ public ApiVO findById(final String id) {
                 tagVOs = 
tagDOS.stream().map(TagVO::buildTagVO).collect(Collectors.toList());
             }
             ApiVO apiVO = ApiVO.buildApiVO(item, tagVOs);
-            if (apiVO.getApiSource().equals(ApiSourceEnum.SWAGGER.getValue())) 
{
+            if (StringUtils.isNotBlank(apiVO.getDocument())) {
                 DocItem docItem = JsonUtils.jsonToObject(apiVO.getDocument(), 
DocItem.class);
-                apiVO.setRequestHeaders(docItem.getRequestHeaders());
-                apiVO.setRequestParameters(docItem.getRequestParameters());
-                apiVO.setResponseParameters(docItem.getResponseParameters());
-                apiVO.setBizCustomCodeList(docItem.getBizCodeList());
+                if (Objects.nonNull(docItem)) {
+                    apiVO.setRequestHeaders(docItem.getRequestHeaders());
+                    apiVO.setRequestParameters(docItem.getRequestParameters());
+                    
apiVO.setResponseParameters(docItem.getResponseParameters());
+                    apiVO.setBizCustomCodeList(docItem.getBizCodeList());
+                }
             }

Review Comment:
   @moremind I think when document is blank or docItem is null, it means the 
API has no document data, so the page simply won't display any API Doc content 
— which is the expected behavior. The null checks (StringUtils.isNotBlank + 
Objects.nonNull) added in this PR already make the code safer than before. No 
additional else branch is needed here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to