feat(template): added hideDefaultGroup default value is false

Configurable for default group display, added hideDefaultGroup default
value is false.

Closes https://gitee.com/smart-doc-team/smart-doc/issues/I4IIC4
This commit is contained in:
cqmike 2021-11-20 17:00:47 +08:00
parent ae1738e9b8
commit 88add1c32e
2 changed files with 28 additions and 4 deletions

View File

@ -163,6 +163,14 @@ public class ApiConfig {
* project group
*/
private String group;
/**
* 是否隐藏默认分组
*
* @since 2.3.2
*/
private boolean hideDefaultGroup;
/**
* @since 1.7.5
* project name
@ -482,6 +490,15 @@ public class ApiConfig {
return this;
}
public boolean isHideDefaultGroup() {
return hideDefaultGroup;
}
public ApiConfig setHideDefaultGroup(boolean hideDefaultGroup) {
this.hideDefaultGroup = hideDefaultGroup;
return this;
}
public List<ApiReqParam> getRequestParams() {
return requestParams;
}

View File

@ -116,13 +116,20 @@ public interface IDocBuildTemplate<T> {
return apiDocList;
}
List<ApiGroup> groups = apiConfig.getGroups();
ApiDoc defaultGroup = ApiDoc.buildGroupApiDoc("default");
List<ApiDoc> finalApiDocs = new ArrayList<>();
finalApiDocs.add(defaultGroup);
ApiDoc defaultGroup = ApiDoc.buildGroupApiDoc("default");
// show default group
AtomicInteger order = new AtomicInteger(1);
defaultGroup.setOrder(order.getAndIncrement());
if (!apiConfig.isHideDefaultGroup()) {
finalApiDocs.add(defaultGroup);
defaultGroup.setOrder(order.getAndIncrement());
if (CollectionUtil.isEmpty(groups)) {
defaultGroup.getChildrenApiDocs().addAll(apiDocList);
}
}
if (CollectionUtil.isEmpty(groups)) {
defaultGroup.getChildrenApiDocs().addAll(apiDocList);
return finalApiDocs;
}
Map<String, String> hasInsert = new HashMap<>();