修改测试样例
This commit is contained in:
parent
59eeb5ebdc
commit
f514501fec
|
@ -243,7 +243,12 @@ public class OpenApiBuilder {
|
|||
if (!isRep && apiMethodDoc.getContentType().equals(DocGlobalConstants.MULTIPART_TYPE)) {
|
||||
// formdata
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
if(apiMethodDoc.isListParam()) {
|
||||
map.put("type", DocGlobalConstants.ARRAY);
|
||||
}
|
||||
else {
|
||||
map.put("type", "object");
|
||||
}
|
||||
Map<String, Object> properties = new LinkedHashMap<>();
|
||||
Map<String, Object> detail;
|
||||
for (ApiParam apiParam : apiMethodDoc.getQueryParams()) {
|
||||
|
@ -261,7 +266,6 @@ public class OpenApiBuilder {
|
|||
} else {
|
||||
detail.put("format", "binary");
|
||||
}
|
||||
|
||||
}
|
||||
properties.put(apiParam.getField(), detail);
|
||||
}
|
||||
|
@ -289,13 +293,11 @@ public class OpenApiBuilder {
|
|||
Map<String, Object> schema = new HashMap<>(10);
|
||||
//当类型为数组时使用
|
||||
Map<String, Object> innerScheme = new HashMap<>(10);
|
||||
|
||||
//去除url中的特殊字符
|
||||
String responseRef = "#/components/schemas/" + apiMethodDoc.getPath().replaceAll(PATH_REGEX, "_") + "response";
|
||||
String requestRef = "#/components/schemas/" + apiMethodDoc.getPath().replaceAll(PATH_REGEX, "_") + "request";
|
||||
|
||||
//如果是数组类型
|
||||
if(DocGlobalConstants.ARRAY.equals(apiMethodDoc.getType())){
|
||||
if(apiMethodDoc.isListParam()){
|
||||
schema.put("type",DocGlobalConstants.ARRAY);
|
||||
if (isRep) {
|
||||
innerScheme.put("$ref", responseRef);
|
||||
|
|
|
@ -182,6 +182,19 @@ public class ApiMethodDoc implements Serializable {
|
|||
*/
|
||||
private String page = "";
|
||||
|
||||
/**
|
||||
* 是否为List数据 openApi
|
||||
*/
|
||||
private boolean listParam = false;
|
||||
|
||||
public boolean isListParam() {
|
||||
return listParam;
|
||||
}
|
||||
|
||||
public void setListParam(boolean listParam) {
|
||||
this.listParam = listParam;
|
||||
}
|
||||
|
||||
public String getMethodId() {
|
||||
return methodId;
|
||||
}
|
||||
|
|
|
@ -320,6 +320,10 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
|||
String simpleTypeName = javaType.getValue();
|
||||
typeName = DocClassUtil.rewriteRequestParam(typeName);
|
||||
gicTypeName = DocClassUtil.rewriteRequestParam(gicTypeName);
|
||||
//if params is collection
|
||||
if(JavaClassValidateUtil.isCollection(typeName)){
|
||||
apiMethodDoc.setListParam(true);
|
||||
}
|
||||
JavaClass javaClass = configBuilder.getJavaProjectBuilder().getClassByName(typeName);
|
||||
String[] globGicName = DocClassUtil.getSimpleGicName(gicTypeName);
|
||||
String comment = this.paramCommentResolve(paramsComments.get(paramName));
|
||||
|
|
|
@ -44,7 +44,8 @@ public class ApiDocTest {
|
|||
//不指定SourcePaths默认加载代码为项目src/main/java下的
|
||||
config.setSourceCodePaths(
|
||||
SourceCodePath.builder().setDesc("本项目代码")
|
||||
.setPath("C:\\Users\\xingzi\\Desktop\\api-doc-test\\src\\main\\java")
|
||||
.setPath("C:\\Users\\xingzi\\Desktop\\api-doc-test")
|
||||
|
||||
//SourcePath.path().setPath("F:\\Personal\\project\\smart\\src\\main\\java")
|
||||
//SourcePath.path().setDesc("加载项目外代码").setPath("E:\\ApplicationPower\\ApplicationPower\\Common-util\\src\\main\\java")
|
||||
);
|
||||
|
@ -66,6 +67,7 @@ public class ApiDocTest {
|
|||
CustomRespField.builder().setName("code").setValue("00000")
|
||||
//.setDesc("响应代码")
|
||||
);
|
||||
config.setPackageFilters("com.power.doc.controller.UserController");
|
||||
//非必须只有当setAllInOne设置为true时文档变更记录才生效,https://gitee.com/sunyurepository/ApplicationPower/issues/IPS4O
|
||||
config.setRevisionLogs(
|
||||
RevisionLog.builder().setRevisionTime("2018/12/15").setAuthor("chen").setRemarks("测试").setStatus("创建").setVersion("V1.0"),
|
||||
|
@ -74,9 +76,9 @@ public class ApiDocTest {
|
|||
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
// OpenApiBuilder.buildOpenApi(config);
|
||||
//HtmlApiDocBuilder.buildApiDoc(config);
|
||||
|
||||
TornaBuilder.buildApiDoc(config);
|
||||
OpenApiBuilder.buildOpenApi(config);
|
||||
long end = System.currentTimeMillis();
|
||||
DateTimeUtil.printRunTime(end, start);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue