fix: fix null exception to group in smart-doc.json

This commit is contained in:
chenqi 2021-08-23 23:11:07 +08:00
parent 1330e887c8
commit be9d40ecf0
4 changed files with 14 additions and 3 deletions

View File

@ -131,7 +131,7 @@ public class BaseDocBuilderTemplate {
} else {
return allInOneName + suffix;
}
} else if (fileName.equals(suffix)) {
} else if (StringUtil.isNotEmpty(fileName) && fileName.endsWith(suffix)) {
return fileName;
} else {
return fileName + suffix;

View File

@ -117,11 +117,15 @@ public interface IDocBuildTemplate<T> {
List<ApiGroup> groups = apiConfig.getGroups();
ApiDoc defaultGroup = ApiDoc.buildGroupApiDoc("default");
List<ApiDoc> finalApiDocs = new ArrayList<>();
finalApiDocs.add(defaultGroup);
AtomicInteger order = new AtomicInteger(1);
defaultGroup.setOrder(order.getAndIncrement());
if (CollectionUtil.isEmpty(groups)) {
defaultGroup.getChildrenApiDocs().addAll(apiDocList);
return finalApiDocs;
}
groups.forEach(group -> {
ApiDoc groupApiDoc = ApiDoc.buildGroupApiDoc(group.getName());
@ -129,6 +133,7 @@ public interface IDocBuildTemplate<T> {
finalApiDocs.add(groupApiDoc);
apiDocList.forEach(doc -> {
// not match, add default group
if (!DocUtil.isMatch(group.getApis(), doc.getPackageName())) {
defaultGroup.getChildrenApiDocs().add(doc);
doc.setOrder(defaultGroup.getChildrenApiDocs().size());

View File

@ -19,7 +19,10 @@ for(revisionLog in revisionLogList){
<%
for(apiGroup in apiDocList){
%>
== ${apiGroup.group}
<%
if(apiGroupLP.size > 1) {%>
==${apiGroup.group}
<%} %>
<%
for(api in apiGroup.childrenApiDocs){
%>

View File

@ -16,7 +16,10 @@ ${revisionLog.version}|${revisionLog.revisionTime}|${revisionLog.status}|${revis
<%
for(apiGroup in apiDocList){
%>
<%
if(apiGroupLP.size > 1) {%>
# ${apiGroup.group}
<%}%>
<%
for(api in apiGroup.childrenApiDocs){
%>