support pageable rewrite
This commit is contained in:
parent
beb50f43d2
commit
faa31f858c
|
@ -1,76 +1,73 @@
|
|||
package com.power.doc;
|
||||
|
||||
import com.power.common.util.DateTimeUtil;
|
||||
import com.power.doc.builder.PostmanJsonBuilder;
|
||||
import com.power.doc.enums.OrderEnum;
|
||||
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.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* ApiDoc测试
|
||||
*
|
||||
* @author yu 2018/06/11.
|
||||
*/
|
||||
public class ApiDocTest {
|
||||
|
||||
/**
|
||||
* 包括设置请求头,缺失注释的字段批量在文档生成期使用定义好的注释
|
||||
*/
|
||||
@Test
|
||||
public void testBuilderControllersApi() {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("aa");
|
||||
list.contains("aa");
|
||||
ApiConfig config = new ApiConfig();
|
||||
config.setServerUrl("http://localhost:8080");
|
||||
//config.setStrict(true);
|
||||
|
||||
config.setAllInOne(true);
|
||||
config.setOutPath("d:\\md2");
|
||||
config.setMd5EncryptedHtmlName(true);
|
||||
//不指定SourcePaths默认加载代码为项目src/main/java下的
|
||||
config.setSourceCodePaths(
|
||||
SourceCodePath.path().setDesc("本项目代码").setPath("C:\\Users\\xingzi\\Desktop\\smart\\api-doc-test\\src\\main\\java")
|
||||
//SourcePath.path().setPath("F:\\Personal\\project\\smart\\src\\main\\java")
|
||||
//SourcePath.path().setDesc("加载项目外代码").setPath("E:\\ApplicationPower\\ApplicationPower\\Common-util\\src\\main\\java")
|
||||
);
|
||||
config.setDataDictionaries(
|
||||
ApiDataDictionary.dict().setTitle("订单字典").setEnumClass(OrderEnum.class).setCodeField("code").setDescField("desc")
|
||||
);
|
||||
//设置请求头,如果没有请求头,可以不用设置
|
||||
/* config.setRequestHeaders(
|
||||
ApiReqHeader.header().setName("access_token").setType("string").setDesc("Basic auth credentials"),
|
||||
ApiReqHeader.header().setName("user_uuid").setType("string").setDesc("User Uuid key")
|
||||
);*/
|
||||
//对于外部jar的类,api-doc目前无法自动获取注释,
|
||||
//如果有这种场景,则自己添加字段和注释,api-doc后期遇到同名字段则直接给相应字段加注释
|
||||
/* config.setCustomResponseFields(
|
||||
// CustomRespField.field().setName("success").setDesc("成功返回true,失败返回false"),
|
||||
// CustomRespField.field().setName("message").setDesc("接口响应信息"),
|
||||
// CustomRespField.field().setName("data").setDesc("接口响应数据"),
|
||||
CustomRespField.field().setName("code").setValue("00000")
|
||||
//.setDesc("响应代码")
|
||||
);*/
|
||||
//非必须只有当setAllInOne设置为true时文档变更记录才生效,https://gitee.com/sunyurepository/ApplicationPower/issues/IPS4O
|
||||
config.setRevisionLogs(
|
||||
RevisionLog.getLog().setRevisionTime("2018/12/15").setAuthor("chen").setRemarks("测试").setStatus("创建").setVersion("V1.0"),
|
||||
RevisionLog.getLog().setRevisionTime("2018/12/16").setAuthor("chen2").setRemarks("测试2").setStatus("修改").setVersion("V2.0")
|
||||
);
|
||||
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
// ApiDocBuilder.builderControllersApi(config);
|
||||
//HtmlApiDocBuilder.builderControllersApi(config);
|
||||
PostmanJsonBuilder.buildPostmanCollection(config);
|
||||
long end = System.currentTimeMillis();
|
||||
DateTimeUtil.printRunTime(end, start);
|
||||
}
|
||||
|
||||
}
|
||||
package com.power.doc;
|
||||
|
||||
import com.power.common.util.DateTimeUtil;
|
||||
import com.power.doc.builder.PostmanJsonBuilder;
|
||||
import com.power.doc.enums.OrderEnum;
|
||||
import com.power.doc.model.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* ApiDoc测试
|
||||
*
|
||||
* @author yu 2018/06/11.
|
||||
*/
|
||||
public class ApiDocTest {
|
||||
|
||||
/**
|
||||
* 包括设置请求头,缺失注释的字段批量在文档生成期使用定义好的注释
|
||||
*/
|
||||
@Test
|
||||
public void testBuilderControllersApi() {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("aa");
|
||||
list.contains("aa");
|
||||
ApiConfig config = new ApiConfig();
|
||||
config.setServerUrl("http://localhost:8080");
|
||||
//config.setStrict(true);
|
||||
|
||||
config.setAllInOne(true);
|
||||
config.setOutPath("d:\\md2");
|
||||
config.setMd5EncryptedHtmlName(true);
|
||||
//不指定SourcePaths默认加载代码为项目src/main/java下的
|
||||
config.setSourceCodePaths(
|
||||
SourceCodePath.path().setDesc("本项目代码").setPath("C:\\Users\\xingzi\\Desktop\\smart\\api-doc-test\\src\\main\\java")
|
||||
//SourcePath.path().setPath("F:\\Personal\\project\\smart\\src\\main\\java")
|
||||
//SourcePath.path().setDesc("加载项目外代码").setPath("E:\\ApplicationPower\\ApplicationPower\\Common-util\\src\\main\\java")
|
||||
);
|
||||
config.setDataDictionaries(
|
||||
ApiDataDictionary.dict().setTitle("订单字典").setEnumClass(OrderEnum.class).setCodeField("code").setDescField("desc")
|
||||
);
|
||||
//设置请求头,如果没有请求头,可以不用设置
|
||||
/* config.setRequestHeaders(
|
||||
ApiReqHeader.header().setName("access_token").setType("string").setDesc("Basic auth credentials"),
|
||||
ApiReqHeader.header().setName("user_uuid").setType("string").setDesc("User Uuid key")
|
||||
);*/
|
||||
//对于外部jar的类,api-doc目前无法自动获取注释,
|
||||
//如果有这种场景,则自己添加字段和注释,api-doc后期遇到同名字段则直接给相应字段加注释
|
||||
config.setCustomResponseFields(
|
||||
// CustomRespField.field().setName("success").setDesc("成功返回true,失败返回false"),
|
||||
// CustomRespField.field().setName("message").setDesc("接口响应信息"),
|
||||
// CustomRespField.field().setName("data").setDesc("接口响应数据"),
|
||||
CustomRespField.field().setName("code").setValue("00000")
|
||||
//.setDesc("响应代码")
|
||||
);
|
||||
//非必须只有当setAllInOne设置为true时文档变更记录才生效,https://gitee.com/sunyurepository/ApplicationPower/issues/IPS4O
|
||||
config.setRevisionLogs(
|
||||
RevisionLog.getLog().setRevisionTime("2018/12/15").setAuthor("chen").setRemarks("测试").setStatus("创建").setVersion("V1.0"),
|
||||
RevisionLog.getLog().setRevisionTime("2018/12/16").setAuthor("chen2").setRemarks("测试2").setStatus("修改").setVersion("V2.0")
|
||||
);
|
||||
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
// ApiDocBuilder.builderControllersApi(config);
|
||||
//HtmlApiDocBuilder.builderControllersApi(config);
|
||||
PostmanJsonBuilder.buildPostmanCollection(config);
|
||||
long end = System.currentTimeMillis();
|
||||
DateTimeUtil.printRunTime(end, start);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,38 +1,36 @@
|
|||
package com.power.doc.util;
|
||||
|
||||
import com.power.doc.model.ApiReturn;
|
||||
import com.power.doc.utils.DocClassUtil;
|
||||
import com.power.doc.utils.JavaClassValidateUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* DocUtil junit test
|
||||
*
|
||||
* @author yu 2018/06/16.
|
||||
*/
|
||||
public class DocClassUtilTest {
|
||||
|
||||
@Test
|
||||
public void testGetSimpleGicName() {
|
||||
char me = 'k';
|
||||
String className = "com.power.doc.controller.Teacher<com.power.doc.controller.Teacher<com.power.doc.controller.User,com.power.doc.controller.User,com.power.doc.controller.User>,com.power.doc.controller.Teacher<com.power.doc.controller.User,com.power.doc.controller.User,com.power.doc.controller.User>,com.power.doc.controller.Teacher<com.power.doc.controller.User,com.power.doc.controller.User,com.power.doc.controller.User>>";
|
||||
String[] arr = DocClassUtil.getSimpleGicName(className);
|
||||
// System.out.println("arr:"+ JSON.toJSONString(arr));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPrimitive() {
|
||||
String typeName = "java.time.LocalDateTime";
|
||||
System.out.println(JavaClassValidateUtil.isPrimitive(typeName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessReturnType() {
|
||||
String typeName = "org.springframework.web.context.request.async.WebAsyncTask";
|
||||
System.out.println(typeName.hashCode());
|
||||
ApiReturn apiReturn = DocClassUtil.processReturnType(typeName);
|
||||
System.out.println(apiReturn.getGenericCanonicalName());
|
||||
System.out.println(apiReturn.getSimpleName());
|
||||
}
|
||||
}
|
||||
package com.power.doc.util;
|
||||
|
||||
import com.power.doc.model.ApiReturn;
|
||||
import com.power.doc.utils.DocClassUtil;
|
||||
import com.power.doc.utils.JavaClassValidateUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* DocUtil junit test
|
||||
*
|
||||
* @author yu 2018/06/16.
|
||||
*/
|
||||
public class DocClassUtilTest {
|
||||
|
||||
@Test
|
||||
public void testGetSimpleGicName() {
|
||||
char me = 'k';
|
||||
String className = "com.power.doc.controller.Teacher<com.power.doc.controller.Teacher<com.power.doc.controller.User,com.power.doc.controller.User,com.power.doc.controller.User>,com.power.doc.controller.Teacher<com.power.doc.controller.User,com.power.doc.controller.User,com.power.doc.controller.User>,com.power.doc.controller.Teacher<com.power.doc.controller.User,com.power.doc.controller.User,com.power.doc.controller.User>>";
|
||||
String[] arr = DocClassUtil.getSimpleGicName(className);
|
||||
// System.out.println("arr:"+ JSON.toJSONString(arr));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPrimitive() {
|
||||
String typeName = "java.time.LocalDateTime";
|
||||
System.out.println(JavaClassValidateUtil.isPrimitive(typeName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessReturnType() {
|
||||
String typeName = "org.springframework.data.domain.Pageable";
|
||||
System.out.println(DocClassUtil.rewriteRequestParam(typeName));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue