change version, update PostmanBuilder method name
This commit is contained in:
parent
d3a8655b97
commit
5b0500d55a
4
pom.xml
4
pom.xml
|
@ -5,7 +5,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>smart-doc</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.8.0</version>
|
||||
<version>1.8.1</version>
|
||||
|
||||
<name>smart-doc</name>
|
||||
<url>https://github.com/shalousun/smart-doc.git</url>
|
||||
|
@ -86,7 +86,7 @@
|
|||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
<version>2.8.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
|
|
@ -28,23 +28,24 @@ public class AdocDocBuilder {
|
|||
*/
|
||||
public static void builderApiDoc(ApiConfig config) {
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
buildApiDoc(config,javaProjectBuilder);
|
||||
buildApiDoc(config, javaProjectBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for plugin
|
||||
* @param config ApiConfig
|
||||
* Only for smart-doc-maven-plugin.
|
||||
*
|
||||
* @param config ApiConfig
|
||||
* @param javaProjectBuilder ProjectDocConfigBuilder
|
||||
*/
|
||||
public static void buildApiDoc(ApiConfig config,JavaProjectBuilder javaProjectBuilder) {
|
||||
public static void buildApiDoc(ApiConfig config, JavaProjectBuilder javaProjectBuilder) {
|
||||
config.setAdoc(true);
|
||||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config,javaProjectBuilder);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
if (config.isAllInOne()) {
|
||||
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder,ALL_IN_ONE_ADOC_TPL, INDEX_DOC);
|
||||
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, ALL_IN_ONE_ADOC_TPL, INDEX_DOC);
|
||||
} else {
|
||||
builderTemplate.buildApiDoc(apiDocList, config, API_DOC_ADOC_TPL, API_EXTENSION);
|
||||
builderTemplate.buildErrorCodeDoc(config, ERROR_CODE_LIST_ADOC_TPL, ERROR_CODE_LIST_ADOC);
|
||||
|
|
|
@ -2,14 +2,11 @@ package com.power.doc.builder;
|
|||
|
||||
import com.power.doc.model.ApiAllData;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.ApiDoc;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
import com.power.doc.template.SpringBootDocBuildTemplate;
|
||||
import com.thoughtworks.qdox.JavaProjectBuilder;
|
||||
|
||||
/**
|
||||
* @since 1.7.9
|
||||
* @author yu 2019/12/7.
|
||||
* @since 1.7.9
|
||||
*/
|
||||
public class ApiDataBuilder {
|
||||
|
||||
|
@ -23,7 +20,7 @@ public class ApiDataBuilder {
|
|||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInitForGetApiData(config);
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
builderTemplate.getApiData(config,javaProjectBuilder);
|
||||
return builderTemplate.getApiData(config,javaProjectBuilder);
|
||||
builderTemplate.getApiData(config, javaProjectBuilder);
|
||||
return builderTemplate.getApiData(config, javaProjectBuilder);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,8 +31,9 @@ public class ApiDocBuilder {
|
|||
}
|
||||
|
||||
/**
|
||||
* Used for plugin
|
||||
* @param config ApiConfig
|
||||
* Only for smart-doc-maven-plugin.
|
||||
*
|
||||
* @param config ApiConfig
|
||||
* @param javaProjectBuilder ProjectDocConfigBuilder
|
||||
*/
|
||||
public static void buildApiDoc(ApiConfig config, JavaProjectBuilder javaProjectBuilder) {
|
||||
|
|
|
@ -59,7 +59,7 @@ public class DocBuilderTemplate {
|
|||
/**
|
||||
* get all api data
|
||||
*
|
||||
* @param config ApiConfig
|
||||
* @param config ApiConfig
|
||||
* @param javaProjectBuilder JavaProjectBuilder
|
||||
* @return ApiAllData
|
||||
*/
|
||||
|
@ -171,7 +171,7 @@ public class DocBuilderTemplate {
|
|||
ApiConfig config = projectBuilder.getApiConfig();
|
||||
FileUtil.mkdirs(config.getOutPath());
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
ApiDoc doc = docBuildTemplate.getSingleApiData(projectBuilder,controllerName);
|
||||
ApiDoc doc = docBuildTemplate.getSingleApiData(projectBuilder, controllerName);
|
||||
Template mapper = BeetlTemplateUtil.getByName(template);
|
||||
mapper.binding(TemplateVariable.DESC.getVariable(), doc.getDesc());
|
||||
mapper.binding(TemplateVariable.NAME.getVariable(), doc.getName());
|
||||
|
|
|
@ -39,26 +39,27 @@ public class HtmlApiDocBuilder {
|
|||
*/
|
||||
public static void buildApiDoc(ApiConfig config) {
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
buildApiDoc(config,javaProjectBuilder);
|
||||
buildApiDoc(config, javaProjectBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for plugin
|
||||
* @param config ApiConfig
|
||||
* Only for smart-doc-maven-plugin.
|
||||
*
|
||||
* @param config ApiConfig
|
||||
* @param javaProjectBuilder ProjectDocConfigBuilder
|
||||
*/
|
||||
public static void buildApiDoc(ApiConfig config,JavaProjectBuilder javaProjectBuilder) {
|
||||
public static void buildApiDoc(ApiConfig config, JavaProjectBuilder javaProjectBuilder) {
|
||||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config,javaProjectBuilder);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
if (config.isAllInOne()) {
|
||||
Template indexCssTemplate = BeetlTemplateUtil.getByName(ALL_IN_ONE_CSS);
|
||||
FileUtil.nioWriteFile(indexCssTemplate.render(), config.getOutPath() + FILE_SEPARATOR + ALL_IN_ONE_CSS);
|
||||
builderTemplate.buildAllInOne(apiDocList, config,javaProjectBuilder, ALL_IN_ONE_HTML_TPL, INDEX_HTML);
|
||||
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, ALL_IN_ONE_HTML_TPL, INDEX_HTML);
|
||||
} else {
|
||||
List<ApiDocDict> apiDocDictList = builderTemplate.buildDictionary(config,javaProjectBuilder);
|
||||
List<ApiDocDict> apiDocDictList = builderTemplate.buildDictionary(config, javaProjectBuilder);
|
||||
buildIndex(apiDocList, config);
|
||||
copyCss(config.getOutPath());
|
||||
buildDoc(apiDocList, config.getOutPath());
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.power.doc.builder;
|
|||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.power.common.util.FileUtil;
|
||||
import com.power.doc.constants.DocGlobalConstants;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
|
@ -15,14 +14,11 @@ import com.power.doc.model.postman.ItemBean;
|
|||
import com.power.doc.model.postman.RequestItem;
|
||||
import com.power.doc.model.postman.request.RequestBean;
|
||||
import com.power.doc.model.postman.request.body.BodyBean;
|
||||
import com.power.doc.model.FormData;
|
||||
import com.power.doc.model.postman.request.header.HeaderBean;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
import com.power.doc.template.SpringBootDocBuildTemplate;
|
||||
import com.thoughtworks.qdox.JavaProjectBuilder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -32,43 +28,32 @@ import java.util.List;
|
|||
*/
|
||||
public class PostmanJsonBuilder {
|
||||
|
||||
public static void postManCreate(ApiConfig config,ProjectDocConfigBuilder configBuilder){
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
RequestItem requestItem = new RequestItem();
|
||||
requestItem.setInfo(new InfoBean(config.getProjectName()));
|
||||
List<ItemBean> itemBeans = new ArrayList<>();
|
||||
apiDocList.forEach(
|
||||
apiDoc -> {
|
||||
ItemBean itemBean = buildItemBean(apiDoc);
|
||||
itemBeans.add(itemBean);
|
||||
}
|
||||
);
|
||||
requestItem.setItem(itemBeans);
|
||||
String filePath = config.getOutPath();
|
||||
filePath = filePath + DocGlobalConstants.POSTMAN_JSON;
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
String data = gson.toJson(requestItem);
|
||||
FileUtil.nioWriteFile(data, filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建postman json
|
||||
*
|
||||
* @param config 配置文件
|
||||
*/
|
||||
public static void buildPostmanApi(ApiConfig config) {
|
||||
public static void buildPostmanCollection(ApiConfig config) {
|
||||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
postManCreate(config,configBuilder);
|
||||
postManCreate(config, configBuilder);
|
||||
|
||||
}
|
||||
public static void buildPostmanApi(ApiConfig config,JavaProjectBuilder projectBuilder) {
|
||||
|
||||
/**
|
||||
* Only for smart-doc-maven-plugin.
|
||||
*
|
||||
* @param config ApiConfig Object
|
||||
* @param projectBuilder QDOX avaProjectBuilder
|
||||
*/
|
||||
public static void buildPostmanCollection(ApiConfig config, JavaProjectBuilder projectBuilder) {
|
||||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, projectBuilder);
|
||||
postManCreate(config,configBuilder);
|
||||
postManCreate(config, configBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,4 +150,24 @@ public class PostmanJsonBuilder {
|
|||
return headerBeans;
|
||||
}
|
||||
|
||||
private static void postManCreate(ApiConfig config, ProjectDocConfigBuilder configBuilder) {
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
RequestItem requestItem = new RequestItem();
|
||||
requestItem.setInfo(new InfoBean(config.getProjectName()));
|
||||
List<ItemBean> itemBeans = new ArrayList<>();
|
||||
apiDocList.forEach(
|
||||
apiDoc -> {
|
||||
ItemBean itemBean = buildItemBean(apiDoc);
|
||||
itemBeans.add(itemBean);
|
||||
}
|
||||
);
|
||||
requestItem.setItem(itemBeans);
|
||||
String filePath = config.getOutPath();
|
||||
filePath = filePath + DocGlobalConstants.POSTMAN_JSON;
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
String data = gson.toJson(requestItem);
|
||||
FileUtil.nioWriteFile(data, filePath);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,12 +53,12 @@ public class ProjectDocConfigBuilder {
|
|||
}
|
||||
javaProjectBuilder.setEncoding(Charset.defaultCharset().toString());
|
||||
this.javaProjectBuilder = javaProjectBuilder;
|
||||
this.loadJavaSource(apiConfig.getSourceCodePaths(),this.javaProjectBuilder);
|
||||
this.loadJavaSource(apiConfig.getSourceCodePaths(), this.javaProjectBuilder);
|
||||
this.initClassFilesMap();
|
||||
this.initCustomResponseFieldsMap(apiConfig);
|
||||
}
|
||||
|
||||
private void loadJavaSource(List<SourceCodePath> paths,JavaProjectBuilder builder) {
|
||||
private void loadJavaSource(List<SourceCodePath> paths, JavaProjectBuilder builder) {
|
||||
if (CollectionUtil.isEmpty(paths)) {
|
||||
builder.addSourceTree(new File(DocGlobalConstants.PROJECT_CODE_PATH));
|
||||
} else {
|
||||
|
@ -85,7 +85,7 @@ public class ProjectDocConfigBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
private void initCustomResponseFieldsMap(ApiConfig config){
|
||||
private void initCustomResponseFieldsMap(ApiConfig config) {
|
||||
if (CollectionUtil.isNotEmpty(config.getCustomResponseFields())) {
|
||||
for (CustomRespField field : config.getCustomResponseFields()) {
|
||||
customRespFieldMap.put(field.getName(), field);
|
||||
|
|
|
@ -101,9 +101,9 @@ public class DocGlobalConstants {
|
|||
|
||||
public static final String JSON_CONTENT_TYPE = "application/json; charset=utf-8";
|
||||
|
||||
public static final String POSTMAN_MODE_FORMDATA ="formdata";
|
||||
public static final String POSTMAN_MODE_FORMDATA = "formdata";
|
||||
|
||||
public static final String POSTMAN_MODE_RAW ="raw";
|
||||
public static final String POSTMAN_MODE_RAW = "raw";
|
||||
|
||||
public static final String SHORT_MULTIPART_FILE_FULLY = "MultipartFile";
|
||||
|
||||
|
|
|
@ -2,9 +2,10 @@ package com.power.doc.constants;
|
|||
|
||||
/**
|
||||
* http methods
|
||||
*
|
||||
* @author yu 2019/11/21.
|
||||
*/
|
||||
public enum Methods {
|
||||
public enum Methods {
|
||||
POST("POST"),
|
||||
GET("GET"),
|
||||
PUT("PUT"),
|
||||
|
@ -13,7 +14,7 @@ public enum Methods {
|
|||
|
||||
private String value;
|
||||
|
||||
Methods(String value){
|
||||
Methods(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,13 +10,12 @@ public enum SpringMvcRequestAnnotationsEnum {
|
|||
|
||||
PATH_VARIABLE("PathVariable"),
|
||||
PATH_VARIABLE_FULLY("org.springframework.web.bind.annotation.PathVariable"),
|
||||
REQ_PARAM ("RequestParam"),
|
||||
REQ_PARAM("RequestParam"),
|
||||
REQ_PARAM_FULLY("org.springframework.web.bind.annotation.RequestParam"),
|
||||
REQUEST_BODY("RequestBody"),
|
||||
REQUEST_BODY_FULLY("org.springframework.web.bind.annotation.RequestBody"),
|
||||
REQUEST_HERDER ("RequestHeader"),
|
||||
REQUEST_HERDER_FULLY ("org.springframework.web.bind.annotation.RequestHeader"),
|
||||
;
|
||||
REQUEST_HERDER("RequestHeader"),
|
||||
REQUEST_HERDER_FULLY("org.springframework.web.bind.annotation.RequestHeader"),;
|
||||
private String value;
|
||||
|
||||
SpringMvcRequestAnnotationsEnum(String value) {
|
||||
|
|
|
@ -22,6 +22,7 @@ public class SpringMVCRequestHeaderHandler {
|
|||
|
||||
/**
|
||||
* handle Spring MVC Request Header
|
||||
*
|
||||
* @param method JavaMethod
|
||||
* @return list of ApiReqHeader
|
||||
*/
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.power.doc.model;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @since 1.7.9
|
||||
* @author yu 2019/12/7.
|
||||
* @since 1.7.9
|
||||
*/
|
||||
public class ApiAllData {
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ public class ApiConfig {
|
|||
|
||||
public void setRequestHeaders(ApiReqHeader... requestHeaders) {
|
||||
this.requestHeaders = CollectionUtil.asList(requestHeaders);
|
||||
this.requestHeaders.stream().map(header -> header.setDesc(header.getDesc()+"(Global)"))
|
||||
this.requestHeaders.stream().map(header -> header.setDesc(header.getDesc() + "(Global)"))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.power.doc.model;
|
||||
|
||||
/**
|
||||
* @since 1.7.9
|
||||
* @author yu 2019/12/7.
|
||||
* @since 1.7.9
|
||||
*/
|
||||
public class ApiErrorCodeDictionary {
|
||||
|
||||
|
@ -25,12 +25,12 @@ public class ApiErrorCodeDictionary {
|
|||
*/
|
||||
private String descField;
|
||||
|
||||
public Class getEnumClass() {
|
||||
return enumClass;
|
||||
public static ApiErrorCodeDictionary dict() {
|
||||
return new ApiErrorCodeDictionary();
|
||||
}
|
||||
|
||||
public static ApiErrorCodeDictionary dict(){
|
||||
return new ApiErrorCodeDictionary();
|
||||
public Class getEnumClass() {
|
||||
return enumClass;
|
||||
}
|
||||
|
||||
public ApiErrorCodeDictionary setEnumClass(Class enumClass) {
|
||||
|
|
|
@ -15,13 +15,14 @@ public class ApiMethodDoc implements Serializable {
|
|||
|
||||
/**
|
||||
* methodId handled by md5
|
||||
* @since 1.7.3 +
|
||||
*
|
||||
* @since 1.7.3 +
|
||||
*/
|
||||
private String methodId;
|
||||
|
||||
/**
|
||||
* method name
|
||||
*
|
||||
* @since 1.7.3 +
|
||||
*/
|
||||
private String name;
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
package com.power.doc.model.postman;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.power.common.util.StringUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -14,14 +11,14 @@ import java.util.UUID;
|
|||
*/
|
||||
public class InfoBean {
|
||||
|
||||
String schema;
|
||||
private String _postman_id = UUID.randomUUID().toString();
|
||||
private String name;
|
||||
String schema ;
|
||||
|
||||
public InfoBean(String name) {
|
||||
if(StringUtils.isBlank(name)){
|
||||
this.name = "smart-doc "+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("YYYY-MM-DD HH:MM:SS"));
|
||||
}
|
||||
else {
|
||||
if (StringUtils.isBlank(name)) {
|
||||
this.name = "smart-doc " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("YYYY-MM-DD HH:MM:SS"));
|
||||
} else {
|
||||
this.name = name;
|
||||
}
|
||||
this.schema = "https://schema.getpostman.com/json/collection/v2.0.0/collection.json";
|
||||
|
|
|
@ -14,6 +14,14 @@ public class BodyBean {
|
|||
private List<FormData> formdata;
|
||||
private BodyOptions options;
|
||||
|
||||
public BodyBean(boolean isFormData) {
|
||||
if (isFormData) {
|
||||
|
||||
} else {
|
||||
this.options = new BodyOptions();
|
||||
}
|
||||
}
|
||||
|
||||
public List<FormData> getFormdata() {
|
||||
return formdata;
|
||||
}
|
||||
|
@ -22,14 +30,6 @@ public class BodyBean {
|
|||
this.formdata = formdata;
|
||||
}
|
||||
|
||||
public BodyBean(boolean isFormData) {
|
||||
if(isFormData){
|
||||
|
||||
}else {
|
||||
this.options = new BodyOptions();
|
||||
}
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
@ -46,14 +46,16 @@ public class BodyBean {
|
|||
this.raw = raw;
|
||||
}
|
||||
|
||||
private class BodyOptions{
|
||||
private class BodyOptions {
|
||||
private Raw raw;
|
||||
|
||||
public BodyOptions() {
|
||||
this.raw = new Raw();
|
||||
}
|
||||
|
||||
private class Raw{
|
||||
private class Raw {
|
||||
private String language;
|
||||
|
||||
Raw() {
|
||||
this.language = "json";
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class ApiRequestExample {
|
|||
|
||||
private boolean json;
|
||||
|
||||
public static ApiRequestExample builder(){
|
||||
public static ApiRequestExample builder() {
|
||||
return new ApiRequestExample();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,7 @@ import com.power.doc.utils.DocUtil;
|
|||
import com.power.doc.utils.JavaClassValidateUtil;
|
||||
import com.thoughtworks.qdox.model.JavaClass;
|
||||
import com.thoughtworks.qdox.model.JavaMethod;
|
||||
import com.thoughtworks.qdox.model.JavaType;
|
||||
import com.thoughtworks.qdox.model.JavaTypeVariable;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -114,7 +111,7 @@ public interface IDocBuildTemplate {
|
|||
|
||||
List<ApiDoc> getApiData(ProjectDocConfigBuilder projectBuilder);
|
||||
|
||||
ApiDoc getSingleApiData(ProjectDocConfigBuilder projectBuilder,String apiClassName);
|
||||
ApiDoc getSingleApiData(ProjectDocConfigBuilder projectBuilder, String apiClassName);
|
||||
|
||||
|
||||
boolean ignoreReturnObject(String typeName);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ApiDoc getSingleApiData(ProjectDocConfigBuilder projectBuilder,String apiClassName) {
|
||||
public ApiDoc getSingleApiData(ProjectDocConfigBuilder projectBuilder, String apiClassName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@ import com.power.common.util.StringUtil;
|
|||
import com.thoughtworks.qdox.model.JavaClass;
|
||||
import com.thoughtworks.qdox.model.JavaField;
|
||||
import com.thoughtworks.qdox.model.JavaMethod;
|
||||
import com.thoughtworks.qdox.model.JavaType;
|
||||
import com.thoughtworks.qdox.model.impl.DefaultJavaField;
|
||||
import com.thoughtworks.qdox.model.impl.DefaultJavaParameterizedType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -117,4 +119,33 @@ public class JavaClassUtil {
|
|||
}
|
||||
return className;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Actual type
|
||||
*
|
||||
* @param javaClass JavaClass
|
||||
* @return JavaClass
|
||||
*/
|
||||
public static JavaClass getActualType(JavaClass javaClass) {
|
||||
return getActualTypes(javaClass).get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* get Actual type list
|
||||
*
|
||||
* @param javaClass JavaClass
|
||||
* @return JavaClass
|
||||
*/
|
||||
public static List<JavaClass> getActualTypes(JavaClass javaClass) {
|
||||
if (null == javaClass) {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
List<JavaClass> javaClassList = new ArrayList<>();
|
||||
List<JavaType> actualTypes = ((DefaultJavaParameterizedType) javaClass).getActualTypeArguments();
|
||||
actualTypes.forEach(javaType -> {
|
||||
JavaClass actualClass = (JavaClass) javaType;
|
||||
javaClassList.add(actualClass);
|
||||
});
|
||||
return javaClassList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public class JavaClassValidateUtil {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if it is the basic data type of json data
|
||||
*
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
package com.power.doc;
|
||||
|
||||
import com.power.common.util.DateTimeUtil;
|
||||
import com.power.common.util.StringUtil;
|
||||
import com.power.doc.builder.HtmlApiDocBuilder;
|
||||
import com.power.doc.builder.PostmanJsonBuilder;
|
||||
import com.power.doc.enums.OrderEnum;
|
||||
import com.power.doc.model.*;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.ApiDataDictionary;
|
||||
import com.power.doc.model.RevisionLog;
|
||||
import com.power.doc.model.SourceCodePath;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
|
@ -67,7 +65,6 @@ public class ApiDocTest {
|
|||
);
|
||||
|
||||
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
// ApiDocBuilder.builderControllersApi(config);
|
||||
//HtmlApiDocBuilder.builderControllersApi(config);
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.power.doc.util;
|
|||
|
||||
import com.power.doc.constants.DocGlobalConstants;
|
||||
import com.power.doc.constants.DocLanguage;
|
||||
import com.power.doc.utils.DocClassUtil;
|
||||
import com.power.doc.utils.DocUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -24,12 +23,12 @@ public class DocUtilTest {
|
|||
@Test
|
||||
public void testFormatAndRemove() {
|
||||
System.setProperty(DocGlobalConstants.DOC_LANGUAGE, DocLanguage.CHINESE.getCode());
|
||||
Map<String,String> params = new HashMap<>();
|
||||
params.put("name","dd");
|
||||
params.put("age","0");
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("name", "dd");
|
||||
params.put("age", "0");
|
||||
String url = "http://localhost:8080/test/{name}";
|
||||
String url2 = "http://localhost:8080/user/getUserById/{name};\thttp://localhost:8080/user/findUserById/{name}";
|
||||
String me = DocUtil.formatAndRemove(url2,params);
|
||||
String me = DocUtil.formatAndRemove(url2, params);
|
||||
System.out.println(params.size());
|
||||
System.out.println(me);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.power.doc.util;
|
||||
|
||||
import com.power.common.util.FileUtil;
|
||||
import com.power.common.util.MD6Util;
|
||||
import com.power.doc.utils.MarkDownUtil;
|
||||
import org.apache.commons.codec.digest.Md5Crypt;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue