From 9f8e54d6706ded5349945c05df8cb9e27359945c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=8C=AF?= <760877972@qq.com> Date: Mon, 13 Jul 2020 11:05:04 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=92=8C=E5=93=8D=E5=BA=94=E7=A4=BA=E4=BE=8B=E7=9A=84=E5=BC=80?= =?UTF-8?q?=E5=85=B3=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../power/doc/builder/DocBuilderTemplate.java | 2 + .../power/doc/constants/TemplateVariable.java | 124 +-- .../java/com/power/doc/model/ApiConfig.java | 923 +++++++++--------- src/main/resources/default.json | 4 +- src/main/resources/template/AllInOne.adoc | 6 +- src/main/resources/template/AllInOne.btl | 226 ++--- src/main/resources/template/AllInOne.html | 4 +- src/main/resources/template/ApiDoc.adoc | 4 +- src/main/resources/template/ApiDoc.btl | 4 +- src/main/resources/template/index-temp.btl | 6 +- 10 files changed, 664 insertions(+), 639 deletions(-) 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 b5c1062..8c5831b 100644 --- a/src/main/java/com/power/doc/model/ApiConfig.java +++ b/src/main/java/com/power/doc/model/ApiConfig.java @@ -1,451 +1,472 @@ -/* - * 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; - - - 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; + + /** + * 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 + */ + private boolean isRequestExample; + /** + * response example + */ + private boolean isResponseExample; + 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; + } + + public boolean isRequestExample() { + return isRequestExample; + } + + public void setRequestExample(boolean requestExample) { + isRequestExample = requestExample; + } + + public boolean isResponseExample() { + return isResponseExample; + } + + public void setResponseExample(boolean responseExample) { + isResponseExample = responseExample; + } +} diff --git a/src/main/resources/default.json b/src/main/resources/default.json index be9fd5f..a86ffcc 100644 --- a/src/main/resources/default.json +++ b/src/main/resources/default.json @@ -8,6 +8,8 @@ "md5EncryptedHtmlName": false, "projectName": "smart-doc", "skipTransientField": true, + "isRequestExample": true, + "isResponseExample": true, "revisionLogs": [ { "version": "1.0", @@ -47,4 +49,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 + From 79f73ff52600f45798db5cb5d48e48da4e94d1d5 Mon Sep 17 00:00:00 2001 From: oppofind <836575280@qq.com> Date: Mon, 13 Jul 2020 13:59:36 +0800 Subject: [PATCH 2/3] update field name --- src/main/java/com/power/doc/model/ApiConfig.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/power/doc/model/ApiConfig.java b/src/main/java/com/power/doc/model/ApiConfig.java index 8c5831b..57bb42a 100644 --- a/src/main/java/com/power/doc/model/ApiConfig.java +++ b/src/main/java/com/power/doc/model/ApiConfig.java @@ -206,12 +206,16 @@ public class ApiConfig { /** * request example + * @since 1.9.0 */ - private boolean isRequestExample; + private boolean requestExample = Boolean.TRUE; + /** * response example + * @since 1.9.0 */ - private boolean isResponseExample; + private boolean responseExample = Boolean.TRUE; + public String getServerUrl() { return serverUrl; } @@ -455,18 +459,18 @@ public class ApiConfig { } public boolean isRequestExample() { - return isRequestExample; + return requestExample; } public void setRequestExample(boolean requestExample) { - isRequestExample = requestExample; + this.requestExample = requestExample; } public boolean isResponseExample() { - return isResponseExample; + return responseExample; } public void setResponseExample(boolean responseExample) { - isResponseExample = responseExample; + this.responseExample = responseExample; } } From c33d8efcd0f218817f4567d4f9dba6a00bc28311 Mon Sep 17 00:00:00 2001 From: oppofind <836575280@qq.com> Date: Mon, 13 Jul 2020 14:04:35 +0800 Subject: [PATCH 3/3] update default.json --- src/main/java/com/power/doc/model/ApiConfig.java | 6 +++--- src/main/resources/default.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/power/doc/model/ApiConfig.java b/src/main/java/com/power/doc/model/ApiConfig.java index 57bb42a..68f8ddd 100644 --- a/src/main/java/com/power/doc/model/ApiConfig.java +++ b/src/main/java/com/power/doc/model/ApiConfig.java @@ -45,7 +45,7 @@ public class ApiConfig { /** * Set comments check mode */ - private boolean isStrict; + private Boolean isStrict = Boolean.FALSE; /** * Merge all api doc into one document @@ -224,11 +224,11 @@ public class ApiConfig { this.serverUrl = serverUrl; } - public boolean isStrict() { + public Boolean getStrict() { return isStrict; } - public void setStrict(boolean strict) { + public void setStrict(Boolean strict) { isStrict = strict; } diff --git a/src/main/resources/default.json b/src/main/resources/default.json index a86ffcc..8fa2d94 100644 --- a/src/main/resources/default.json +++ b/src/main/resources/default.json @@ -8,8 +8,8 @@ "md5EncryptedHtmlName": false, "projectName": "smart-doc", "skipTransientField": true, - "isRequestExample": true, - "isResponseExample": true, + "requestExample": true, + "responseExample": true, "revisionLogs": [ { "version": "1.0",