diff --git a/src/main/java/com/power/doc/builder/DocBuilderTemplate.java b/src/main/java/com/power/doc/builder/DocBuilderTemplate.java index 58cab10..ffa9e7a 100644 --- a/src/main/java/com/power/doc/builder/DocBuilderTemplate.java +++ b/src/main/java/com/power/doc/builder/DocBuilderTemplate.java @@ -106,6 +106,8 @@ public class DocBuilderTemplate extends BaseDocBuilderTemplate { tpl.binding(TemplateVariable.VERSION.getVariable(), now); tpl.binding(TemplateVariable.CREATE_TIME.getVariable(), strTime); tpl.binding(TemplateVariable.PROJECT_NAME.getVariable(), config.getProjectName()); + tpl.binding(TemplateVariable.REQUEST_EXAMPLE.getVariable(), config.isRequestExample()); + tpl.binding(TemplateVariable.RESPONSE_EXAMPLE.getVariable(), config.isResponseExample()); if (CollectionUtil.isEmpty(errorCodeList)) { tpl.binding(TemplateVariable.DICT_ORDER.getVariable(), apiDocList.size() + 1); } else { diff --git a/src/main/java/com/power/doc/constants/TemplateVariable.java b/src/main/java/com/power/doc/constants/TemplateVariable.java index e391b86..8f60654 100644 --- a/src/main/java/com/power/doc/constants/TemplateVariable.java +++ b/src/main/java/com/power/doc/constants/TemplateVariable.java @@ -1,62 +1,62 @@ -/* - * smart-doc https://github.com/shalousun/smart-doc - * - * Copyright (C) 2018-2020 smart-doc - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.power.doc.constants; - -/** - * @author yu 2019/9/21. - */ -public enum TemplateVariable { - DESC("desc"), - NAME("name"), - LIST("list"), - API_DOC_LIST("apiDocList"), - ERROR_CODE_LIST("errorCodeList"), - VERSION_LIST("revisionLogList"), - DEPENDENCY_LIST("dependencyList"), - HOME_PAGE("homePage"), - HTML("html"), - TITLE("title"), - ERROR_LIST_TITLE("errorListTitle"), - CREATE_TIME("createTime"), - PROJECT_NAME("projectName"), - DICT_LIST("dictList"), - DICT_LIST_TITLE("dictListTitle"), - DICT_ORDER("dictListOrder"), - VERSION("version"), - PROTOCOL("protocol"), - AUTHOR("author"), - URI("uri"), - RPC_CONSUMER_CONFIG("consumerConfigExample") - ; - - - private String variable; - - TemplateVariable(String variable) { - this.variable = variable; - } - - public String getVariable() { - return this.variable; - } -} +/* + * smart-doc https://github.com/shalousun/smart-doc + * + * Copyright (C) 2018-2020 smart-doc + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.power.doc.constants; + +/** + * @author yu 2019/9/21. + */ +public enum TemplateVariable { + DESC("desc"), + NAME("name"), + LIST("list"), + API_DOC_LIST("apiDocList"), + ERROR_CODE_LIST("errorCodeList"), + VERSION_LIST("revisionLogList"), + DEPENDENCY_LIST("dependencyList"), + HOME_PAGE("homePage"), + HTML("html"), + TITLE("title"), + ERROR_LIST_TITLE("errorListTitle"), + CREATE_TIME("createTime"), + PROJECT_NAME("projectName"), + DICT_LIST("dictList"), + DICT_LIST_TITLE("dictListTitle"), + DICT_ORDER("dictListOrder"), + VERSION("version"), + PROTOCOL("protocol"), + AUTHOR("author"), + URI("uri"), + RPC_CONSUMER_CONFIG("consumerConfigExample"), + REQUEST_EXAMPLE("isRequestExample"), + RESPONSE_EXAMPLE("isResponseExample"); + + private String variable; + + TemplateVariable(String variable) { + this.variable = variable; + } + + public String getVariable() { + return this.variable; + } +} diff --git a/src/main/java/com/power/doc/model/ApiConfig.java b/src/main/java/com/power/doc/model/ApiConfig.java index 5ef916c..b70a93e 100644 --- a/src/main/java/com/power/doc/model/ApiConfig.java +++ b/src/main/java/com/power/doc/model/ApiConfig.java @@ -1,464 +1,490 @@ -/* - * smart-doc - * - * Copyright (C) 2018-2020 smart-doc - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.power.doc.model; - -import com.power.common.util.CollectionUtil; -import com.power.doc.constants.DocLanguage; -import com.power.doc.model.rpc.RpcApiDependency; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * Description: - * api config info - * - * @author yu 2018/06/18. - */ -public class ApiConfig { - - /** - * Web server base url - */ - private String serverUrl; - - /** - * Set comments check mode - */ - private boolean isStrict; - - /** - * Merge all api doc into one document - */ - private boolean allInOne; - - /** - * output path - */ - private String outPath; - - - /** - * source path - */ - private List sourceCodePaths; - - /** - * list of Request headers - */ - private List requestHeaders; - - /** - * @since 1.7.5 - * cover old all in one markdown - */ - private boolean coverOld; - - /** - * list of custom response filed - */ - private List customResponseFields; - - /** - * List of error code - * - * @return - */ - - private List errorCodes; - - /** - * controller package filters - */ - private String packageFilters; - - /** - * List of change log - */ - private List revisionLogs; - - /** - * @since 1.7+ - */ - private boolean md5EncryptedHtmlName; - - /** - * language support - * - * @since 1.7+ - */ - private DocLanguage language; - - /** - * adoc flag - */ - private boolean adoc; - - - /** - * api data dictionary - */ - private List dataDictionaries; - - /** - * @since 1.7.9 - * api error code dictionary - */ - private List errorCodeDictionaries; - - /** - * list of custom response filed - */ - private List apiObjectReplacements; - - /** - * list of rpc api dependencies - */ - private List rpcApiDependencies; - - /** - * list of api constant - */ - private List apiConstants; - - /** - * @since 1.7.5 - * project name - */ - private String projectName; - - /** - * Skip Transient Field - */ - private boolean skipTransientField = true; - - /** - * @since 1.7.10 - * default show author - */ - private boolean showAuthor = true; - - /** - * convert request field to underline - * - * @since 1.8.7 - */ - private boolean requestFieldToUnderline; - - /** - * convert response field to underline - * - * @since 1.8.7 - */ - private boolean responseFieldToUnderline; - - /** - * sort by title - * - * @since 1.8.7 - */ - private boolean sortByTitle; - - /** - * is rest api doc - * - * @since 1.8.7 - */ - private Boolean showJavaType = Boolean.FALSE; - - /** - * is inline enum field comment - * @since 1.8.8 - */ - private Boolean inlineEnum = Boolean.FALSE; - - /** - * rpc consumer config example - * @since 1.8.7 - */ - private String rpcConsumerConfig; - - /** - * recursion limit - * @since 1.8.8 - */ - private int recursionLimit = 7; - - /** - * name of index - */ - private String indexFileName; - - - public String getIndexFileName() { - return indexFileName; - } - - public void setIndexFileName(String indexFileName) { - this.indexFileName = indexFileName; - } - - public String getServerUrl() { - return serverUrl; - } - - public void setServerUrl(String serverUrl) { - this.serverUrl = serverUrl; - } - - public boolean isStrict() { - return isStrict; - } - - public void setStrict(boolean strict) { - isStrict = strict; - } - - public String getOutPath() { - return outPath; - } - - public void setOutPath(String outPath) { - this.outPath = outPath; - } - - public List getRequestHeaders() { - return requestHeaders; - } - - public void setRequestHeaders(ApiReqHeader... requestHeaders) { - this.requestHeaders = CollectionUtil.asList(requestHeaders); - this.requestHeaders.stream().map(header -> header.setDesc(header.getDesc() + "(Global)")) - .collect(Collectors.toList()); - } - - public List getCustomResponseFields() { - return customResponseFields; - } - - public void setCustomResponseFields(CustomRespField... customResponseFields) { - this.customResponseFields = CollectionUtil.asList(customResponseFields); - } - - - public List getErrorCodes() { - return errorCodes; - } - - public void setErrorCodes(List errorCodes) { - this.errorCodes = errorCodes; - } - - public List getSourceCodePaths() { - return sourceCodePaths; - } - - public void setSourceCodePaths(SourceCodePath... sourcePaths) { - this.sourceCodePaths = CollectionUtil.asList(sourcePaths); - } - - public boolean isAllInOne() { - return allInOne; - } - - public void setAllInOne(boolean allInOne) { - this.allInOne = allInOne; - } - - public String getPackageFilters() { - return packageFilters; - } - - public void setPackageFilters(String packageFilters) { - this.packageFilters = packageFilters; - } - - public List getRevisionLogs() { - return revisionLogs; - } - - public void setRevisionLogs(RevisionLog... revisionLogs) { - this.revisionLogs = CollectionUtil.asList(revisionLogs); - } - - - public boolean isMd5EncryptedHtmlName() { - return md5EncryptedHtmlName; - } - - public void setMd5EncryptedHtmlName(boolean md5EncryptedHtmlName) { - this.md5EncryptedHtmlName = md5EncryptedHtmlName; - } - - public DocLanguage getLanguage() { - return language; - } - - public void setLanguage(DocLanguage language) { - this.language = language; - } - - public boolean isAdoc() { - return adoc; - } - - public void setAdoc(boolean adoc) { - this.adoc = adoc; - } - - public List getDataDictionaries() { - return dataDictionaries; - } - - public void setDataDictionaries(ApiDataDictionary... dataDictConfigs) { - this.dataDictionaries = CollectionUtil.asList(dataDictConfigs); - } - - public ApiDataDictionary getDataDictionary(String enumClassSimpleName) { - return this.dataDictionaries.stream().filter((apiDataDictionary -> - enumClassSimpleName.equalsIgnoreCase(apiDataDictionary.getEnumClassName()))) - .findFirst().orElse(new ApiDataDictionary()); - } - - public List getErrorCodeDictionaries() { - return errorCodeDictionaries; - } - - public void setErrorCodeDictionaries(ApiErrorCodeDictionary... errorCodeDictConfigs) { - this.errorCodeDictionaries = CollectionUtil.asList(errorCodeDictConfigs); - } - - public List getApiObjectReplacements() { - return apiObjectReplacements; - } - - public void setApiObjectReplacements(ApiObjectReplacement... apiObjectReplaces) { - this.apiObjectReplacements = CollectionUtil.asList(apiObjectReplaces); - } - - public List getRpcApiDependencies() { - return rpcApiDependencies; - } - - public void setRpcApiDependencies(RpcApiDependency... rpcApiDependencies) { - this.rpcApiDependencies = CollectionUtil.asList(rpcApiDependencies); - } - - public List getApiConstants() { - return apiConstants; - } - - public void setApiConstants(ApiConstant... apiConstants) { - this.apiConstants = CollectionUtil.asList(apiConstants); - } - - public boolean isCoverOld() { - return coverOld; - } - - public void setCoverOld(boolean coverOld) { - this.coverOld = coverOld; - } - - public String getProjectName() { - return projectName; - } - - public void setProjectName(String projectName) { - this.projectName = projectName; - } - - public boolean isSkipTransientField() { - return skipTransientField; - } - - public void setSkipTransientField(boolean skipTransientField) { - this.skipTransientField = skipTransientField; - } - - public boolean isShowAuthor() { - return showAuthor; - } - - public void setShowAuthor(boolean showAuthor) { - this.showAuthor = showAuthor; - } - - public boolean isRequestFieldToUnderline() { - return requestFieldToUnderline; - } - - public void setRequestFieldToUnderline(boolean requestFieldToUnderline) { - this.requestFieldToUnderline = requestFieldToUnderline; - } - - public boolean isResponseFieldToUnderline() { - return responseFieldToUnderline; - } - - public void setResponseFieldToUnderline(boolean responseFieldToUnderline) { - this.responseFieldToUnderline = responseFieldToUnderline; - } - - public boolean isSortByTitle() { - return sortByTitle; - } - - public void setSortByTitle(boolean sortByTitle) { - this.sortByTitle = sortByTitle; - } - - public Boolean getShowJavaType() { - return showJavaType; - } - - public void setShowJavaType(Boolean showJavaType) { - this.showJavaType = showJavaType; - } - - public String getRpcConsumerConfig() { - return rpcConsumerConfig; - } - - public void setRpcConsumerConfig(String rpcConsumerConfig) { - this.rpcConsumerConfig = rpcConsumerConfig; - } - - public Boolean getInlineEnum() { - return inlineEnum; - } - - public void setInlineEnum(Boolean inlineEnum) { - this.inlineEnum = inlineEnum; - } - - public int getRecursionLimit() { - return recursionLimit; - } - - public void setRecursionLimit(int recursionLimit) { - this.recursionLimit = recursionLimit; - } - - -} +/* + * smart-doc + * + * Copyright (C) 2018-2020 smart-doc + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.power.doc.model; + +import com.power.common.util.CollectionUtil; +import com.power.doc.constants.DocLanguage; +import com.power.doc.model.rpc.RpcApiDependency; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * Description: + * api config info + * + * @author yu 2018/06/18. + */ +public class ApiConfig { + + /** + * Web server base url + */ + private String serverUrl; + + /** + * Set comments check mode + */ + private Boolean isStrict = Boolean.FALSE; + + /** + * Merge all api doc into one document + */ + private boolean allInOne; + + /** + * output path + */ + private String outPath; + + + /** + * source path + */ + private List sourceCodePaths; + + /** + * list of Request headers + */ + private List requestHeaders; + + /** + * @since 1.7.5 + * cover old all in one markdown + */ + private boolean coverOld; + + /** + * list of custom response filed + */ + private List customResponseFields; + + /** + * List of error code + * + * @return + */ + + private List errorCodes; + + /** + * controller package filters + */ + private String packageFilters; + + /** + * List of change log + */ + private List revisionLogs; + + /** + * @since 1.7+ + */ + private boolean md5EncryptedHtmlName; + + /** + * language support + * + * @since 1.7+ + */ + private DocLanguage language; + + /** + * adoc flag + */ + private boolean adoc; + + + /** + * api data dictionary + */ + private List dataDictionaries; + + /** + * @since 1.7.9 + * api error code dictionary + */ + private List errorCodeDictionaries; + + /** + * list of custom response filed + */ + private List apiObjectReplacements; + + /** + * list of rpc api dependencies + */ + private List rpcApiDependencies; + + /** + * list of api constant + */ + private List apiConstants; + + /** + * @since 1.7.5 + * project name + */ + private String projectName; + + /** + * Skip Transient Field + */ + private boolean skipTransientField = true; + + /** + * @since 1.7.10 + * default show author + */ + private boolean showAuthor = true; + + /** + * convert request field to underline + * + * @since 1.8.7 + */ + private boolean requestFieldToUnderline; + + /** + * convert response field to underline + * + * @since 1.8.7 + */ + private boolean responseFieldToUnderline; + + /** + * sort by title + * + * @since 1.8.7 + */ + private boolean sortByTitle; + + /** + * is rest api doc + * + * @since 1.8.7 + */ + private Boolean showJavaType = Boolean.FALSE; + + /** + * is inline enum field comment + * @since 1.8.8 + */ + private Boolean inlineEnum = Boolean.FALSE; + + /** + * rpc consumer config example + * @since 1.8.7 + */ + private String rpcConsumerConfig; + + /** + * recursion limit + * @since 1.8.8 + */ + private int recursionLimit = 7; + + /** + * request example + * @since 1.9.0 + */ + private boolean requestExample = Boolean.TRUE; + + /** + * response example + * @since 1.9.0 + */ + private boolean responseExample = Boolean.TRUE; + + /** + * name of index + */ + private String indexFileName; + + + public String getIndexFileName() { + return indexFileName; + } + + public void setIndexFileName(String indexFileName) { + this.indexFileName = indexFileName; + } + + public String getServerUrl() { + return serverUrl; + } + + public void setServerUrl(String serverUrl) { + this.serverUrl = serverUrl; + } + + public Boolean getStrict() { + return isStrict; + } + + public void setStrict(Boolean strict) { + isStrict = strict; + } + + public String getOutPath() { + return outPath; + } + + public void setOutPath(String outPath) { + this.outPath = outPath; + } + + public List getRequestHeaders() { + return requestHeaders; + } + + public void setRequestHeaders(ApiReqHeader... requestHeaders) { + this.requestHeaders = CollectionUtil.asList(requestHeaders); + this.requestHeaders.stream().map(header -> header.setDesc(header.getDesc() + "(Global)")) + .collect(Collectors.toList()); + } + + public List getCustomResponseFields() { + return customResponseFields; + } + + public void setCustomResponseFields(CustomRespField... customResponseFields) { + this.customResponseFields = CollectionUtil.asList(customResponseFields); + } + + + public List getErrorCodes() { + return errorCodes; + } + + public void setErrorCodes(List errorCodes) { + this.errorCodes = errorCodes; + } + + public List getSourceCodePaths() { + return sourceCodePaths; + } + + public void setSourceCodePaths(SourceCodePath... sourcePaths) { + this.sourceCodePaths = CollectionUtil.asList(sourcePaths); + } + + public boolean isAllInOne() { + return allInOne; + } + + public void setAllInOne(boolean allInOne) { + this.allInOne = allInOne; + } + + public String getPackageFilters() { + return packageFilters; + } + + public void setPackageFilters(String packageFilters) { + this.packageFilters = packageFilters; + } + + public List getRevisionLogs() { + return revisionLogs; + } + + public void setRevisionLogs(RevisionLog... revisionLogs) { + this.revisionLogs = CollectionUtil.asList(revisionLogs); + } + + + public boolean isMd5EncryptedHtmlName() { + return md5EncryptedHtmlName; + } + + public void setMd5EncryptedHtmlName(boolean md5EncryptedHtmlName) { + this.md5EncryptedHtmlName = md5EncryptedHtmlName; + } + + public DocLanguage getLanguage() { + return language; + } + + public void setLanguage(DocLanguage language) { + this.language = language; + } + + public boolean isAdoc() { + return adoc; + } + + public void setAdoc(boolean adoc) { + this.adoc = adoc; + } + + public List getDataDictionaries() { + return dataDictionaries; + } + + public void setDataDictionaries(ApiDataDictionary... dataDictConfigs) { + this.dataDictionaries = CollectionUtil.asList(dataDictConfigs); + } + + public ApiDataDictionary getDataDictionary(String enumClassSimpleName) { + return this.dataDictionaries.stream().filter((apiDataDictionary -> + enumClassSimpleName.equalsIgnoreCase(apiDataDictionary.getEnumClassName()))) + .findFirst().orElse(new ApiDataDictionary()); + } + + public List getErrorCodeDictionaries() { + return errorCodeDictionaries; + } + + public void setErrorCodeDictionaries(ApiErrorCodeDictionary... errorCodeDictConfigs) { + this.errorCodeDictionaries = CollectionUtil.asList(errorCodeDictConfigs); + } + + public List getApiObjectReplacements() { + return apiObjectReplacements; + } + + public void setApiObjectReplacements(ApiObjectReplacement... apiObjectReplaces) { + this.apiObjectReplacements = CollectionUtil.asList(apiObjectReplaces); + } + + public List getRpcApiDependencies() { + return rpcApiDependencies; + } + + public void setRpcApiDependencies(RpcApiDependency... rpcApiDependencies) { + this.rpcApiDependencies = CollectionUtil.asList(rpcApiDependencies); + } + + public List getApiConstants() { + return apiConstants; + } + + public void setApiConstants(ApiConstant... apiConstants) { + this.apiConstants = CollectionUtil.asList(apiConstants); + } + + public boolean isCoverOld() { + return coverOld; + } + + public void setCoverOld(boolean coverOld) { + this.coverOld = coverOld; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public boolean isSkipTransientField() { + return skipTransientField; + } + + public void setSkipTransientField(boolean skipTransientField) { + this.skipTransientField = skipTransientField; + } + + public boolean isShowAuthor() { + return showAuthor; + } + + public void setShowAuthor(boolean showAuthor) { + this.showAuthor = showAuthor; + } + + public boolean isRequestFieldToUnderline() { + return requestFieldToUnderline; + } + + public void setRequestFieldToUnderline(boolean requestFieldToUnderline) { + this.requestFieldToUnderline = requestFieldToUnderline; + } + + public boolean isResponseFieldToUnderline() { + return responseFieldToUnderline; + } + + public void setResponseFieldToUnderline(boolean responseFieldToUnderline) { + this.responseFieldToUnderline = responseFieldToUnderline; + } + + public boolean isSortByTitle() { + return sortByTitle; + } + + public void setSortByTitle(boolean sortByTitle) { + this.sortByTitle = sortByTitle; + } + + public Boolean getShowJavaType() { + return showJavaType; + } + + public void setShowJavaType(Boolean showJavaType) { + this.showJavaType = showJavaType; + } + + public String getRpcConsumerConfig() { + return rpcConsumerConfig; + } + + public void setRpcConsumerConfig(String rpcConsumerConfig) { + this.rpcConsumerConfig = rpcConsumerConfig; + } + + public Boolean getInlineEnum() { + return inlineEnum; + } + + public void setInlineEnum(Boolean inlineEnum) { + this.inlineEnum = inlineEnum; + } + + public int getRecursionLimit() { + return recursionLimit; + } + + public void setRecursionLimit(int recursionLimit) { + this.recursionLimit = recursionLimit; + } + + public boolean isRequestExample() { + return requestExample; + } + + public void setRequestExample(boolean requestExample) { + this.requestExample = requestExample; + } + + public boolean isResponseExample() { + return responseExample; + } + + public void setResponseExample(boolean responseExample) { + this.responseExample = responseExample; + } +} \ No newline at end of file diff --git a/src/main/resources/default.json b/src/main/resources/default.json index 0bcdca1..ef67ac5 100644 --- a/src/main/resources/default.json +++ b/src/main/resources/default.json @@ -9,6 +9,8 @@ "md5EncryptedHtmlName": false, "projectName": "smart-doc", "skipTransientField": true, + "requestExample": true, + "responseExample": true, "revisionLogs": [ { "version": "1.0", @@ -48,4 +50,4 @@ "desc": "测试" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/template/AllInOne.adoc b/src/main/resources/template/AllInOne.adoc index 9948082..7b34312 100644 --- a/src/main/resources/template/AllInOne.adoc +++ b/src/main/resources/template/AllInOne.adoc @@ -64,7 +64,7 @@ for(param in doc.requestParams){ |==================== <%}%> -<%if(isNotEmpty(doc.requestUsage)){%> +<%if(isNotEmpty(doc.requestUsage)&&isRequestExample){%> *Request-example:* ---- ${doc.requestUsage} @@ -85,7 +85,7 @@ for(param in doc.responseParams){ |==================== <%}%> -<%if(isNotEmpty(doc.responseUsage)){%> +<%if(isNotEmpty(doc.responseUsage)&&isResponseExample){%> *Response-example:* ---- ${doc.responseUsage} @@ -127,4 +127,4 @@ for(dataDict in dict.dataDictList){ <%}%> |==================== <%}%> -<%}%> \ No newline at end of file +<%}%> diff --git a/src/main/resources/template/AllInOne.btl b/src/main/resources/template/AllInOne.btl index c8e948f..59efa7e 100644 --- a/src/main/resources/template/AllInOne.btl +++ b/src/main/resources/template/AllInOne.btl @@ -1,113 +1,113 @@ -<%if(isNotEmpty(projectName)){%> -# ${projectName} -<%}%> -<%if(isNotEmpty(revisionLogList)){%> -Version | Update Time | Status | Author | Description ----|---|---|---|--- -<% -for(revisionLog in revisionLogList){ -%> -${revisionLog.version}|${revisionLog.revisionTime}|${revisionLog.status}|${revisionLog.author}|${revisionLog.remarks} -<%}%> - -<%}%> - - -<% -for(api in apiDocList){ -%> -## ${api.desc} -<% -for(doc in api.list){ -%> -<%if(doc.deprecated){%> -### ~~${doc.desc}~~ -<%}else{%> -### ${doc.desc} -<%}%> -**URL:** ${doc.url} - -**Type:** ${doc.type} - -<%if(isNotEmpty(doc.author)){%> -**Author:** ${doc.author} -<%}%> - -**Content-Type:** ${doc.contentType} - -**Description:** ${doc.detail} -<%if(isNotEmpty(doc.headers)){%> - -**Request-headers:** - -Header | Type|Description|Required|Since ----|---|---|---|---- -${doc.headers} -<%}%> -<%if(isNotEmpty(doc.requestParams)){%> - -**Request-parameters:** - -Parameter | Type|Description|Required|Since ----|---|---|---|--- -<% -for(param in doc.requestParams){ -%> -${param.field}|${param.type}|${param.desc}|${param.required}|${param.version} -<%}%> -<%}%> - -<%if(isNotEmpty(doc.requestUsage)){%> -**Request-example:** -``` -${doc.requestUsage} -``` -<%}%> -<%if(isNotEmpty(doc.responseParams)){%> -**Response-fields:** - -Field | Type|Description|Since ----|---|---|--- -<% -for(param in doc.responseParams){ -%> -${param.field}|${param.type}|${param.desc}|${param.version} -<%}%> -<%}%> - -<%if(isNotEmpty(doc.responseUsage)){%> -**Response-example:** -``` -${doc.responseUsage} -``` -<%}%> - -<% } %> -<% } %> -<%if(isNotEmpty(errorCodeList)){%> -## ${errorListTitle} -Error code |Description ----|--- -<% -for(error in errorCodeList){ -%> -${error.value}|${error.desc} -<%}%> -<%}%> - -<%if(isNotEmpty(dictList)){%> -## ${dictListTitle} -<% -for(dict in dictList){ -%> -### ${dict.title} - -Code |Type|Description ----|---|--- -<% -for(dataDict in dict.dataDictList){ -%> -${dataDict.value}|${dataDict.type}|${dataDict.desc} -<%}%> -<%}%> -<%}%> \ No newline at end of file +<%if(isNotEmpty(projectName)){%> +# ${projectName} +<%}%> +<%if(isNotEmpty(revisionLogList)){%> +Version | Update Time | Status | Author | Description +---|---|---|---|--- +<% +for(revisionLog in revisionLogList){ +%> +${revisionLog.version}|${revisionLog.revisionTime}|${revisionLog.status}|${revisionLog.author}|${revisionLog.remarks} +<%}%> + +<%}%> + + +<% +for(api in apiDocList){ +%> +## ${api.desc} +<% +for(doc in api.list){ +%> +<%if(doc.deprecated){%> +### ~~${doc.desc}~~ +<%}else{%> +### ${doc.desc} +<%}%> +**URL:** ${doc.url} + +**Type:** ${doc.type} + +<%if(isNotEmpty(doc.author)){%> +**Author:** ${doc.author} +<%}%> + +**Content-Type:** ${doc.contentType} + +**Description:** ${doc.detail} +<%if(isNotEmpty(doc.headers)){%> + +**Request-headers:** + +Header | Type|Description|Required|Since +---|---|---|---|---- +${doc.headers} +<%}%> +<%if(isNotEmpty(doc.requestParams)){%> + +**Request-parameters:** + +Parameter | Type|Description|Required|Since +---|---|---|---|--- +<% +for(param in doc.requestParams){ +%> +${param.field}|${param.type}|${param.desc}|${param.required}|${param.version} +<%}%> +<%}%> + +<%if(isNotEmpty(doc.requestUsage)&&isRequestExample){%> +**Request-example:** +``` +${doc.requestUsage} +``` +<%}%> +<%if(isNotEmpty(doc.responseParams)){%> +**Response-fields:** + +Field | Type|Description|Since +---|---|---|--- +<% +for(param in doc.responseParams){ +%> +${param.field}|${param.type}|${param.desc}|${param.version} +<%}%> +<%}%> + +<%if(isNotEmpty(doc.responseUsage)&&isResponseExample){%> +**Response-example:** +``` +${doc.responseUsage} +``` +<%}%> + +<% } %> +<% } %> +<%if(isNotEmpty(errorCodeList)){%> +## ${errorListTitle} +Error code |Description +---|--- +<% +for(error in errorCodeList){ +%> +${error.value}|${error.desc} +<%}%> +<%}%> + +<%if(isNotEmpty(dictList)){%> +## ${dictListTitle} +<% +for(dict in dictList){ +%> +### ${dict.title} + +Code |Type|Description +---|---|--- +<% +for(dataDict in dict.dataDictList){ +%> +${dataDict.value}|${dataDict.type}|${dataDict.desc} +<%}%> +<%}%> +<%}%> diff --git a/src/main/resources/template/AllInOne.html b/src/main/resources/template/AllInOne.html index 9910bf0..496f44b 100644 --- a/src/main/resources/template/AllInOne.html +++ b/src/main/resources/template/AllInOne.html @@ -1,4 +1,4 @@ -<%if(isNotEmpty(projectName)){%>${projectName}<%}else{%>API Reference<%}%>
<%if(isNotEmpty(revisionLogList)){%>
<%for(revisionLog in revisionLogList){%><%}%>
VersionUpdate TimeStatusAuthorDescription

${revisionLog.version}

${revisionLog.revisionTime}

${revisionLog.status}

${revisionLog.author}

${revisionLog.remarks}

<%}%><%for(api in apiDocList){%>

${api.order}. ${api.desc}

<%for(doc in api.list){%>

<%if(doc.deprecated){%>${api.order}.${doc.order}. ${doc.desc}<%}else{%>${api.order}.${doc.order}. ${doc.desc}<%}%>

Type: ${doc.type}

<%if(isNotEmpty(doc.author)){%>

Author: ${doc.author}

<%}%>

Content-Type: ${doc.contentType}

Description: ${doc.detail}

<%if(isNotEmpty(doc.requestHeaders)){%>

Request-headers:

<%for(header in doc.requestHeaders){%><%}%>
HeaderTypeDescriptionRequiredSince

${header.name}

${header.type}

${header.desc}

${header.required}

${header.since}

<%}%><%if(isNotEmpty(doc.requestParams)){%>

Request-parameters:

<%for(param in doc.requestParams){%><%}%>
ParameterTypeDescriptionRequiredSince

${param.field}

${param.type}

${param.desc}

${param.required}

${param.version}

<%}%><%if(isNotEmpty(doc.requestUsage)){%>

Request-example:

${doc.requestUsage}
<%}%><%if(isNotEmpty(doc.responseParams)){%>

Response-fields:

<%for(param in doc.responseParams){%><%}%>
FieldTypeDescriptionSince

${param.field}

${param.type}

${param.desc}

${param.version}

<%}%><%if(isNotEmpty(doc.responseUsage)){%>

Response-example:

${doc.responseUsage}
<%}%>
<%}%>
<%}%><%if(isNotEmpty(errorCodeList)){%>

${apiDocList.~size+1}. ${errorListTitle}

<%for(error in errorCodeList){%><%}%>
Error codeDescription

${error.value}

${error.desc}

<%}%><%if(isNotEmpty(dictList)){%>

${dictListOrder}. ${dictListTitle}

<% for(dict in dictList){ %>

${dictListOrder}.${dict.order}. ${dict.title}

<%for(dataDict in dict.dataDictList){%><%}%>
CodeTypeDescription

${dataDict.value}

${dataDict.type}

${dataDict.desc}

<%}%>
<%}%>
Generated by smart-doc at ${createTime}Suggestions,contact,support and error reporting on Gitee or Github
+<%if(isNotEmpty(projectName)){%>${projectName}<%}else{%>API Reference<%}%>
<%if(isNotEmpty(revisionLogList)){%>
<%for(revisionLog in revisionLogList){%><%}%>
VersionUpdate TimeStatusAuthorDescription

${revisionLog.version}

${revisionLog.revisionTime}

${revisionLog.status}

${revisionLog.author}

${revisionLog.remarks}

<%}%><%for(api in apiDocList){%>

${api.order}. ${api.desc}

<%for(doc in api.list){%>

<%if(doc.deprecated){%>${api.order}.${doc.order}. ${doc.desc}<%}else{%>${api.order}.${doc.order}. ${doc.desc}<%}%>

Type: ${doc.type}

<%if(isNotEmpty(doc.author)){%>

Author: ${doc.author}

<%}%>

Content-Type: ${doc.contentType}

Description: ${doc.detail}

<%if(isNotEmpty(doc.requestHeaders)){%>

Request-headers:

<%for(header in doc.requestHeaders){%><%}%>
HeaderTypeDescriptionRequiredSince

${header.name}

${header.type}

${header.desc}

${header.required}

${header.since}

<%}%><%if(isNotEmpty(doc.requestParams)){%>

Request-parameters:

<%for(param in doc.requestParams){%><%}%>
ParameterTypeDescriptionRequiredSince

${param.field}

${param.type}

${param.desc}

${param.required}

${param.version}

<%}%><%if(isNotEmpty(doc.requestUsage)&&isRequestExample){%>

Request-example:

${doc.requestUsage}
<%}%><%if(isNotEmpty(doc.responseParams)){%>

Response-fields:

<%for(param in doc.responseParams){%><%}%>
FieldTypeDescriptionSince

${param.field}

${param.type}

${param.desc}

${param.version}

<%}%><%if(isNotEmpty(doc.responseUsage)&&isResponseExample){%>

Response-example:

${doc.responseUsage}
<%}%>
<%}%>
<%}%><%if(isNotEmpty(errorCodeList)){%>

${apiDocList.~size+1}. ${errorListTitle}

<%for(error in errorCodeList){%><%}%>
Error codeDescription

${error.value}

${error.desc}

<%}%><%if(isNotEmpty(dictList)){%>

${dictListOrder}. ${dictListTitle}

<% for(dict in dictList){ %>

${dictListOrder}.${dict.order}. ${dict.title}

<%for(dataDict in dict.dataDictList){%><%}%>
CodeTypeDescription

${dataDict.value}

${dataDict.type}

${dataDict.desc}

<%}%>
<%}%>
Generated by smart-doc at ${createTime}Suggestions,contact,support and error reporting on Gitee or Github
- \ No newline at end of file + diff --git a/src/main/resources/template/ApiDoc.adoc b/src/main/resources/template/ApiDoc.adoc index d65efd2..d9b9d1c 100644 --- a/src/main/resources/template/ApiDoc.adoc +++ b/src/main/resources/template/ApiDoc.adoc @@ -46,7 +46,7 @@ for(param in doc.requestParams){ <%}%> |==================== -<%if(isNotEmpty(doc.requestUsage)){%> +<%if(isNotEmpty(doc.requestUsage)&&isRequestExample){%> *Request-example:* ---- ${doc.requestUsage} @@ -67,7 +67,7 @@ for(param in doc.responseParams){ <%}%> |==================== -<%if(isNotEmpty(doc.responseUsage)){%> +<%if(isNotEmpty(doc.responseUsage)&&isResponseExample){%> *Response-example:* ---- ${doc.responseUsage} diff --git a/src/main/resources/template/ApiDoc.btl b/src/main/resources/template/ApiDoc.btl index c70518d..2b76d44 100644 --- a/src/main/resources/template/ApiDoc.btl +++ b/src/main/resources/template/ApiDoc.btl @@ -40,7 +40,7 @@ ${param.field}|${param.type}|${param.desc}|${param.required}|${param.version} <%}%> <%}%> -<%if(isNotEmpty(doc.requestUsage)){%> +<%if(isNotEmpty(doc.requestUsage)&&isRequestExample){%> **Request-example:** ``` ${doc.requestUsage} @@ -58,7 +58,7 @@ ${param.field}|${param.type}|${param.desc}|${param.version} <%}%> <%}%> -<%if(isNotEmpty(doc.responseUsage)){%> +<%if(isNotEmpty(doc.responseUsage)&&isResponseExample){%> **Response-example:** ``` ${doc.responseUsage} diff --git a/src/main/resources/template/index-temp.btl b/src/main/resources/template/index-temp.btl index 704ec20..009bc97 100644 --- a/src/main/resources/template/index-temp.btl +++ b/src/main/resources/template/index-temp.btl @@ -91,7 +91,7 @@ <%}%> - <%if(isNotEmpty(doc.requestUsage)){%> + <%if(isNotEmpty(doc.requestUsage)&&isRequestExample){%>

Request-example:

${doc.requestUsage}
              
@@ -113,7 +113,7 @@ <%}%> - <%if(isNotEmpty(doc.responseUsage)){%> + <%if(isNotEmpty(doc.responseUsage)&&isResponseExample){%>

Response-example:

${doc.responseUsage}
               
@@ -132,4 +132,4 @@ - \ No newline at end of file +