diff --git a/src/main/java/com/power/doc/builder/OpenApiBuilder.java b/src/main/java/com/power/doc/builder/OpenApiBuilder.java index c63001b..b4b6c7f 100644 --- a/src/main/java/com/power/doc/builder/OpenApiBuilder.java +++ b/src/main/java/com/power/doc/builder/OpenApiBuilder.java @@ -378,8 +378,6 @@ public class OpenApiBuilder { requiredList.add(param.getField()); } String field = param.getField(); - //去除filed的前缀 - field = field.replaceAll("└─", "").replaceAll(" ", ""); propertiesData.put(field, buildPropertiesData(param)); } diff --git a/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java b/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java index 16df363..87663d2 100644 --- a/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java +++ b/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java @@ -47,6 +47,7 @@ import java.util.stream.Stream; import static com.power.doc.constants.DocGlobalConstants.FILE_CONTENT_TYPE; import static com.power.doc.constants.DocGlobalConstants.JSON_CONTENT_TYPE; import static com.power.doc.constants.DocTags.IGNORE; +import static com.power.doc.constants.DocTags.PARAM; /** * @author yu 2019/12/21. @@ -214,12 +215,18 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { ApiRequestExample requestExample = ApiRequestExample.builder(); out: for (JavaParameter parameter : parameterList) { + JavaType javaType = parameter.getType(); String paramName = parameter.getName(); String typeName = javaType.getFullyQualifiedName(); String gicTypeName = javaType.getGenericCanonicalName(); String rewriteClassName = null; + String commentClass = paramsComments.get(paramName); + //过滤请求参数 + if(Objects.nonNull(commentClass) && commentClass.contains(IGNORE)){ + continue; + } if (Objects.nonNull(commentClass) && !DocGlobalConstants.NO_COMMENTS_FOUND.equals(commentClass)) { String[] comments = commentClass.split("\\|"); rewriteClassName = comments[comments.length - 1]; @@ -424,6 +431,9 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { out: for (JavaParameter parameter : parameterList) { String paramName = parameter.getName(); + if(Objects.nonNull(paramTagMap.get(paramName)) && paramTagMap.get(paramName).contains(IGNORE)){ + continue; + } if (jsonParamSet.size() > 0 && !jsonParamSet.contains(paramName)) { continue; } diff --git a/src/main/java/com/power/doc/utils/ApiParamTreeUtil.java b/src/main/java/com/power/doc/utils/ApiParamTreeUtil.java index ec9b71a..89736c0 100644 --- a/src/main/java/com/power/doc/utils/ApiParamTreeUtil.java +++ b/src/main/java/com/power/doc/utils/ApiParamTreeUtil.java @@ -18,12 +18,15 @@ public class ApiParamTreeUtil { List params = new ArrayList<>(); // find root for (ApiParam apiParam : apiParamList) { + //去除filed的前缀 + apiParam.setField(apiParam.getField().replaceAll("└─", "").replaceAll(" ", "")); // pid == 0 if (apiParam.getPid() == 0) { params.add(apiParam); } } for (ApiParam apiParam : params) { + //去除filed的前缀 apiParam.setChildren(getChild(apiParam.getId(), apiParamList)); } return params; diff --git a/src/test/java/com/power/doc/ApiDocTest.java b/src/test/java/com/power/doc/ApiDocTest.java index 7eafd68..0f2f7c2 100644 --- a/src/test/java/com/power/doc/ApiDocTest.java +++ b/src/test/java/com/power/doc/ApiDocTest.java @@ -66,7 +66,7 @@ public class ApiDocTest { long start = System.currentTimeMillis(); - OpenApiBuilder.buildOpenApi(config); + // OpenApiBuilder.buildOpenApi(config); HtmlApiDocBuilder.buildApiDoc(config); long end = System.currentTimeMillis(); DateTimeUtil.printRunTime(end, start);