Add Framework extend support
This commit is contained in:
parent
c59d58134a
commit
69e6859cfc
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
package com.power.doc.builder;
|
||||
|
||||
import com.power.doc.factory.BuildTemplateFactory;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.ApiDoc;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
|
@ -65,7 +66,7 @@ public class AdocDocBuilder {
|
|||
config.setParamsDataToTree(false);
|
||||
config.setAdoc(true);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
if (config.isAllInOne()) {
|
||||
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, ALL_IN_ONE_ADOC_TPL, INDEX_DOC);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
package com.power.doc.builder;
|
||||
|
||||
import com.power.common.util.DateTimeUtil;
|
||||
import com.power.doc.factory.BuildTemplateFactory;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.ApiDoc;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
|
@ -64,7 +65,7 @@ public class ApiDocBuilder {
|
|||
config.setAdoc(false);
|
||||
config.setParamsDataToTree(false);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
if (config.isAllInOne()) {
|
||||
String version = config.isCoverOld() ? "" : "-V" + DateTimeUtil.long2Str(System.currentTimeMillis(), DATE_FORMAT);
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.power.common.util.DateTimeUtil;
|
|||
import com.power.common.util.StringUtil;
|
||||
import com.power.doc.constants.DocGlobalConstants;
|
||||
import com.power.doc.constants.DocLanguage;
|
||||
import com.power.doc.constants.FrameworkEnum;
|
||||
import com.power.doc.constants.TemplateVariable;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.RevisionLog;
|
||||
|
@ -84,6 +85,10 @@ public class BaseDocBuilderTemplate {
|
|||
.setStatus("auto")
|
||||
);
|
||||
}
|
||||
if (StringUtil.isEmpty(config.getFramework())) {
|
||||
config.setFramework(FrameworkEnum.SPRING.getFramework());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Map<String, String> setDirectoryLanguageVariable(ApiConfig config, Template mapper) {
|
||||
|
@ -109,7 +114,7 @@ public class BaseDocBuilderTemplate {
|
|||
return titleMap;
|
||||
}
|
||||
|
||||
public void setCssCDN(ApiConfig config,Template template) {
|
||||
public void setCssCDN(ApiConfig config, Template template) {
|
||||
if (DocLanguage.CHINESE.equals(config.getLanguage())) {
|
||||
template.binding(TemplateVariable.CSS_CND.getVariable(), CSS_CDN_CH);
|
||||
} else {
|
||||
|
|
|
@ -22,18 +22,19 @@
|
|||
*/
|
||||
package com.power.doc.builder;
|
||||
|
||||
import com.power.common.util.*;
|
||||
import com.power.doc.constants.DocGlobalConstants;
|
||||
import com.power.common.util.CollectionUtil;
|
||||
import com.power.common.util.DateTimeUtil;
|
||||
import com.power.common.util.FileUtil;
|
||||
import com.power.doc.constants.DocLanguage;
|
||||
import com.power.doc.constants.HighlightStyle;
|
||||
import com.power.doc.constants.TemplateVariable;
|
||||
import com.power.doc.factory.BuildTemplateFactory;
|
||||
import com.power.doc.model.*;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
import com.power.doc.template.SpringBootDocBuildTemplate;
|
||||
import com.power.doc.utils.BeetlTemplateUtil;
|
||||
import com.power.doc.utils.DocUtil;
|
||||
import com.thoughtworks.qdox.JavaProjectBuilder;
|
||||
import com.thoughtworks.qdox.model.JavaClass;
|
||||
import org.beetl.core.Template;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -134,7 +135,7 @@ public class DocBuilderTemplate extends BaseDocBuilderTemplate {
|
|||
tpl.binding(TemplateVariable.PROJECT_NAME.getVariable(), config.getProjectName());
|
||||
tpl.binding(TemplateVariable.REQUEST_EXAMPLE.getVariable(), config.isRequestExample());
|
||||
tpl.binding(TemplateVariable.RESPONSE_EXAMPLE.getVariable(), config.isResponseExample());
|
||||
setCssCDN(config,tpl);
|
||||
setCssCDN(config, tpl);
|
||||
if (CollectionUtil.isEmpty(errorCodeList)) {
|
||||
tpl.binding(TemplateVariable.DICT_ORDER.getVariable(), apiDocList.size() + 1);
|
||||
} else {
|
||||
|
@ -316,7 +317,7 @@ public class DocBuilderTemplate extends BaseDocBuilderTemplate {
|
|||
public void buildSingleApi(ProjectDocConfigBuilder projectBuilder, String controllerName, String template, String fileExtension) {
|
||||
ApiConfig config = projectBuilder.getApiConfig();
|
||||
FileUtil.mkdirs(config.getOutPath());
|
||||
IDocBuildTemplate<ApiDoc> docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
IDocBuildTemplate<ApiDoc> docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
ApiDoc doc = docBuildTemplate.getSingleApiData(projectBuilder, controllerName);
|
||||
Template mapper = BeetlTemplateUtil.getByName(template);
|
||||
mapper.binding(TemplateVariable.DESC.getVariable(), doc.getDesc());
|
||||
|
@ -330,7 +331,7 @@ public class DocBuilderTemplate extends BaseDocBuilderTemplate {
|
|||
this.checkAndInitForGetApiData(config);
|
||||
config.setMd5EncryptedHtmlName(true);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
return docBuildTemplate.getApiData(configBuilder);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
package com.power.doc.builder;
|
||||
|
||||
import com.power.common.util.FileUtil;
|
||||
import com.power.doc.factory.BuildTemplateFactory;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.ApiDoc;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
|
@ -68,7 +69,7 @@ public class HtmlApiDocBuilder {
|
|||
builderTemplate.checkAndInit(config);
|
||||
config.setParamsDataToTree(false);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
Template indexCssTemplate = BeetlTemplateUtil.getByName(ALL_IN_ONE_CSS);
|
||||
FileUtil.nioWriteFile(indexCssTemplate.render(), config.getOutPath() + FILE_SEPARATOR + ALL_IN_ONE_CSS);
|
||||
|
|
|
@ -27,8 +27,9 @@ import com.power.common.util.FileUtil;
|
|||
import com.power.common.util.StringUtil;
|
||||
import com.power.doc.constants.DocGlobalConstants;
|
||||
import com.power.doc.constants.Methods;
|
||||
import com.power.doc.factory.BuildTemplateFactory;
|
||||
import com.power.doc.model.*;
|
||||
import com.power.doc.template.SpringBootDocBuildTemplate;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
import com.power.doc.utils.DocUtil;
|
||||
import com.power.doc.utils.JsonUtil;
|
||||
import com.thoughtworks.qdox.JavaProjectBuilder;
|
||||
|
@ -78,7 +79,7 @@ public class OpenApiBuilder {
|
|||
*/
|
||||
private static void openApiCreate(ApiConfig config, ProjectDocConfigBuilder configBuilder) {
|
||||
config.setParamsDataToTree(true);
|
||||
SpringBootDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
Map<String, Object> json = new HashMap<>(8);
|
||||
json.put("openapi", "3.0.3");
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.power.common.util.CollectionUtil;
|
|||
import com.power.common.util.FileUtil;
|
||||
import com.power.common.util.StringUtil;
|
||||
import com.power.doc.constants.DocGlobalConstants;
|
||||
import com.power.doc.factory.BuildTemplateFactory;
|
||||
import com.power.doc.model.*;
|
||||
import com.power.doc.model.postman.InfoBean;
|
||||
import com.power.doc.model.postman.ItemBean;
|
||||
|
@ -240,7 +241,7 @@ public class PostmanJsonBuilder {
|
|||
}
|
||||
|
||||
private static void postManCreate(ApiConfig config, ProjectDocConfigBuilder configBuilder) {
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
RequestItem requestItem = new RequestItem();
|
||||
requestItem.setInfo(new InfoBean(config.getProjectName()));
|
||||
|
|
|
@ -27,11 +27,13 @@ import com.power.common.util.CollectionUtil;
|
|||
import com.power.common.util.OkHttp3Util;
|
||||
import com.power.common.util.StringUtil;
|
||||
import com.power.doc.constants.TornaConstants;
|
||||
import com.power.doc.factory.BuildTemplateFactory;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.ApiDoc;
|
||||
import com.power.doc.model.torna.Apis;
|
||||
import com.power.doc.model.torna.TornaApi;
|
||||
import com.power.doc.model.torna.TornaDic;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
import com.power.doc.template.SpringBootDocBuildTemplate;
|
||||
import com.power.doc.utils.DocUtil;
|
||||
import com.power.doc.utils.TornaUtil;
|
||||
|
@ -76,7 +78,8 @@ public class TornaBuilder {
|
|||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
List<ApiDoc> apiDocList = new SpringBootDocBuildTemplate().getApiData(configBuilder);
|
||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
buildTorna(apiDocList, config, javaProjectBuilder);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,11 @@
|
|||
package com.power.doc.builder.rpc;
|
||||
|
||||
import com.power.doc.builder.ProjectDocConfigBuilder;
|
||||
import com.power.doc.constants.FrameworkEnum;
|
||||
import com.power.doc.factory.BuildTemplateFactory;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.rpc.RpcApiDoc;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
import com.power.doc.template.RpcDocBuildTemplate;
|
||||
import com.thoughtworks.qdox.JavaProjectBuilder;
|
||||
|
||||
|
@ -58,12 +61,13 @@ public class RpcAdocBuilder {
|
|||
* @param javaProjectBuilder ProjectDocConfigBuilder
|
||||
*/
|
||||
public static void buildApiDoc(ApiConfig config, JavaProjectBuilder javaProjectBuilder) {
|
||||
config.setFramework(FrameworkEnum.DUBBO.getFramework());
|
||||
config.setAdoc(true);
|
||||
config.setShowJavaType(true);
|
||||
RpcDocBuilderTemplate builderTemplate = new RpcDocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
RpcDocBuildTemplate docBuildTemplate = new RpcDocBuildTemplate();
|
||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
List<RpcApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
if (config.isAllInOne()) {
|
||||
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, RPC_ALL_IN_ONE_ADOC_TPL, INDEX_DOC);
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
*/
|
||||
package com.power.doc.builder.rpc;
|
||||
|
||||
import com.power.common.util.StringUtil;
|
||||
import com.power.doc.constants.FrameworkEnum;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.rpc.RpcApiAllData;
|
||||
import com.thoughtworks.qdox.JavaProjectBuilder;
|
||||
|
@ -39,6 +41,9 @@ public class RpcApiDataBuilder {
|
|||
*/
|
||||
public static RpcApiAllData getApiData(ApiConfig config) {
|
||||
config.setShowJavaType(true);
|
||||
if (StringUtil.isEmpty(config.getFramework())) {
|
||||
config.setFramework(FrameworkEnum.DUBBO.getFramework());
|
||||
}
|
||||
RpcDocBuilderTemplate builderTemplate = new RpcDocBuilderTemplate();
|
||||
builderTemplate.checkAndInitForGetApiData(config);
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
|
|
|
@ -25,15 +25,17 @@ package com.power.doc.builder.rpc;
|
|||
import com.power.common.util.CollectionUtil;
|
||||
import com.power.common.util.DateTimeUtil;
|
||||
import com.power.common.util.FileUtil;
|
||||
import com.power.common.util.StringUtil;
|
||||
import com.power.doc.builder.BaseDocBuilderTemplate;
|
||||
import com.power.doc.builder.ProjectDocConfigBuilder;
|
||||
import com.power.doc.constants.FrameworkEnum;
|
||||
import com.power.doc.constants.TemplateVariable;
|
||||
import com.power.doc.factory.BuildTemplateFactory;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.ApiErrorCode;
|
||||
import com.power.doc.model.rpc.RpcApiAllData;
|
||||
import com.power.doc.model.rpc.RpcApiDoc;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
import com.power.doc.template.RpcDocBuildTemplate;
|
||||
import com.power.doc.utils.BeetlTemplateUtil;
|
||||
import com.power.doc.utils.DocUtil;
|
||||
import com.thoughtworks.qdox.JavaProjectBuilder;
|
||||
|
@ -56,6 +58,9 @@ public class RpcDocBuilderTemplate extends BaseDocBuilderTemplate {
|
|||
private static long now = System.currentTimeMillis();
|
||||
|
||||
public void checkAndInit(ApiConfig config) {
|
||||
if (StringUtil.isEmpty(config.getFramework())) {
|
||||
config.setFramework(FrameworkEnum.DUBBO.getFramework());
|
||||
}
|
||||
super.checkAndInit(config);
|
||||
config.setOutPath(config.getOutPath() + FILE_SEPARATOR + RPC_OUT_DIR);
|
||||
}
|
||||
|
@ -189,7 +194,7 @@ public class RpcDocBuilderTemplate extends BaseDocBuilderTemplate {
|
|||
this.checkAndInitForGetApiData(config);
|
||||
config.setMd5EncryptedHtmlName(true);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
IDocBuildTemplate docBuildTemplate = new RpcDocBuildTemplate();
|
||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
return docBuildTemplate.getApiData(configBuilder);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,11 @@ package com.power.doc.builder.rpc;
|
|||
|
||||
import com.power.common.util.FileUtil;
|
||||
import com.power.doc.builder.ProjectDocConfigBuilder;
|
||||
import com.power.doc.constants.FrameworkEnum;
|
||||
import com.power.doc.factory.BuildTemplateFactory;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.rpc.RpcApiDoc;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
import com.power.doc.template.RpcDocBuildTemplate;
|
||||
import com.power.doc.utils.BeetlTemplateUtil;
|
||||
import com.thoughtworks.qdox.JavaProjectBuilder;
|
||||
|
@ -68,7 +71,7 @@ public class RpcHtmlBuilder {
|
|||
RpcDocBuilderTemplate builderTemplate = new RpcDocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
RpcDocBuildTemplate docBuildTemplate = new RpcDocBuildTemplate();
|
||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
List<RpcApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
Template indexCssTemplate = BeetlTemplateUtil.getByName(ALL_IN_ONE_CSS);
|
||||
FileUtil.nioWriteFile(indexCssTemplate.render(), config.getOutPath() + FILE_SEPARATOR + ALL_IN_ONE_CSS);
|
||||
|
|
|
@ -24,6 +24,7 @@ package com.power.doc.builder.rpc;
|
|||
|
||||
import com.power.common.util.DateTimeUtil;
|
||||
import com.power.doc.builder.ProjectDocConfigBuilder;
|
||||
import com.power.doc.factory.BuildTemplateFactory;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.rpc.RpcApiDoc;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
|
@ -63,7 +64,7 @@ public class RpcMarkdownBuilder {
|
|||
RpcDocBuilderTemplate builderTemplate = new RpcDocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
IDocBuildTemplate docBuildTemplate = new RpcDocBuildTemplate();
|
||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
List<RpcApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
if (config.isAllInOne()) {
|
||||
String version = config.isCoverOld() ? "" : "-V" + DateTimeUtil.long2Str(System.currentTimeMillis(), DATE_FORMAT);
|
||||
|
|
|
@ -28,12 +28,14 @@ import com.power.common.util.OkHttp3Util;
|
|||
import com.power.common.util.StringUtil;
|
||||
import com.power.doc.builder.ProjectDocConfigBuilder;
|
||||
import com.power.doc.constants.TornaConstants;
|
||||
import com.power.doc.factory.BuildTemplateFactory;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.rpc.RpcApiDoc;
|
||||
import com.power.doc.model.torna.Apis;
|
||||
import com.power.doc.model.torna.DubboInfo;
|
||||
import com.power.doc.model.torna.TornaApi;
|
||||
import com.power.doc.model.torna.TornaDic;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
import com.power.doc.template.RpcDocBuildTemplate;
|
||||
import com.power.doc.utils.DocUtil;
|
||||
import com.power.doc.utils.TornaUtil;
|
||||
|
@ -77,7 +79,7 @@ public class RpcTornaBuilder {
|
|||
RpcDocBuilderTemplate builderTemplate = new RpcDocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
RpcDocBuildTemplate docBuildTemplate = new RpcDocBuildTemplate();
|
||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||
List<RpcApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
buildTorna(apiDocList, config, javaProjectBuilder);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public enum FrameworkEnum {
|
|||
/**
|
||||
* Spring Framework
|
||||
*/
|
||||
SPRING("spring", "com.power.doc.template.RpcDocBuildTemplate.SpringBootDocBuildTemplate");
|
||||
SPRING("spring", "com.power.doc.template.SpringBootDocBuildTemplate");
|
||||
|
||||
/**
|
||||
* Framework name
|
||||
|
|
|
@ -28,23 +28,25 @@ import com.power.doc.template.IDocBuildTemplate;
|
|||
/**
|
||||
* @author yu 2021/6/27.
|
||||
*/
|
||||
public class TemplateFactory {
|
||||
public class BuildTemplateFactory {
|
||||
|
||||
/**
|
||||
* Get Doc build template
|
||||
*
|
||||
* @param framework framework name
|
||||
* @param <T> API doc type
|
||||
* @return Implements of IDocBuildTemplate
|
||||
*/
|
||||
public static IDocBuildTemplate getDocBuildTemplate(String framework) {
|
||||
public static <T> IDocBuildTemplate<T> getDocBuildTemplate(String framework) {
|
||||
String className = FrameworkEnum.getClassNameByFramework(framework);
|
||||
try {
|
||||
return (IDocBuildTemplate) Class.forName(FrameworkEnum.getClassNameByFramework(framework)).newInstance();
|
||||
return (IDocBuildTemplate) Class.forName(className).newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("The currently supported framework name can only be=> dubbo, spring .");
|
||||
throw new RuntimeException("The class=>" + className + " is not found , smart-doc currently supported framework name can only be set in [dubbo, spring].");
|
||||
}
|
||||
return null;
|
||||
}
|
|
@ -332,6 +332,11 @@ public class ApiConfig {
|
|||
*/
|
||||
private String author;
|
||||
|
||||
/**
|
||||
* smart-doc supported framework, if not set default is spring,
|
||||
*/
|
||||
private String framework;
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
@ -792,6 +797,14 @@ public class ApiConfig {
|
|||
this.customRequestFields = CollectionUtil.asList(customRequestFields);
|
||||
}
|
||||
|
||||
public String getFramework() {
|
||||
return framework;
|
||||
}
|
||||
|
||||
public void setFramework(String framework) {
|
||||
this.framework = framework;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
|
@ -811,6 +824,8 @@ public class ApiConfig {
|
|||
.append(coverOld);
|
||||
sb.append(",\"customResponseFields\":")
|
||||
.append(customResponseFields);
|
||||
sb.append(",\"customRequestFields\":")
|
||||
.append(customRequestFields);
|
||||
sb.append(",\"errorCodes\":")
|
||||
.append(errorCodes);
|
||||
sb.append(",\"packageFilters\":\"")
|
||||
|
@ -871,6 +886,8 @@ public class ApiConfig {
|
|||
.append(displayActualType);
|
||||
sb.append(",\"responseBodyAdvice\":")
|
||||
.append(responseBodyAdvice);
|
||||
sb.append(",\"requestBodyAdvice\":")
|
||||
.append(requestBodyAdvice);
|
||||
sb.append(",\"style\":\"")
|
||||
.append(style).append('\"');
|
||||
sb.append(",\"createDebugPage\":")
|
||||
|
@ -891,6 +908,10 @@ public class ApiConfig {
|
|||
.append(debugEnvUrl).append('\"');
|
||||
sb.append(",\"tornaDebug\":")
|
||||
.append(tornaDebug);
|
||||
sb.append(",\"author\":\"")
|
||||
.append(author).append('\"');
|
||||
sb.append(",\"framework\":\"")
|
||||
.append(framework).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue