增加忽略请求参数的设置 使用 @param User user信息 @ignore 忽略user参数

This commit is contained in:
xingzi 2020-08-20 12:46:44 +08:00
parent cdfd663c44
commit e96b685fdb
4 changed files with 14 additions and 3 deletions

View File

@ -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));
}

View File

@ -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<ApiDoc> {
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<ApiDoc> {
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;
}

View File

@ -18,12 +18,15 @@ public class ApiParamTreeUtil {
List<ApiParam> params = new ArrayList<>();
// find root
for (ApiParam apiParam : apiParamList) {
//去除filed的前缀
apiParam.setField(apiParam.getField().replaceAll("└─", "").replaceAll("&nbsp;", ""));
// pid == 0
if (apiParam.getPid() == 0) {
params.add(apiParam);
}
}
for (ApiParam apiParam : params) {
//去除filed的前缀
apiParam.setChildren(getChild(apiParam.getId(), apiParamList));
}
return params;

View File

@ -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);