忽略请求参数
This commit is contained in:
parent
5d32eced7b
commit
c427604e23
|
@ -86,7 +86,7 @@ public class JsonBuildHelper {
|
|||
}
|
||||
int nextLevel = counter + 1;
|
||||
registryClasses.put(typeName, typeName);
|
||||
if (JavaClassValidateUtil.isMvcIgnoreParams(typeName)) {
|
||||
if (JavaClassValidateUtil.isMvcIgnoreParams(typeName,builder.getApiConfig().getIgnoreParam())) {
|
||||
if (DocGlobalConstants.MODE_AND_VIEW_FULLY.equals(typeName)) {
|
||||
return "Forward or redirect to a page view.";
|
||||
} else {
|
||||
|
|
|
@ -98,7 +98,7 @@ public interface IDocBuildTemplate<T> {
|
|||
ApiReturn apiReturn = DocClassUtil.processReturnType(method.getReturnType().getGenericCanonicalName());
|
||||
String returnType = apiReturn.getGenericCanonicalName();
|
||||
String typeName = apiReturn.getSimpleName();
|
||||
if (this.ignoreReturnObject(typeName)) {
|
||||
if (this.ignoreReturnObject(typeName,projectBuilder.getApiConfig().getIgnoreParam())) {
|
||||
return null;
|
||||
}
|
||||
if (JavaClassValidateUtil.isPrimitive(typeName)) {
|
||||
|
@ -140,6 +140,6 @@ public interface IDocBuildTemplate<T> {
|
|||
|
||||
T getSingleApiData(ProjectDocConfigBuilder projectBuilder, String apiClassName);
|
||||
|
||||
boolean ignoreReturnObject(String typeName);
|
||||
boolean ignoreReturnObject(String typeName,List<String> ignoreParams);
|
||||
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class RpcDocBuildTemplate implements IDocBuildTemplate<RpcApiDoc> {
|
|||
return null;
|
||||
}
|
||||
|
||||
public boolean ignoreReturnObject(String typeName) {
|
||||
public boolean ignoreReturnObject(String typeName,List<String> ignoreParams) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,8 +90,8 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreReturnObject(String typeName) {
|
||||
if (JavaClassValidateUtil.isMvcIgnoreParams(typeName)) {
|
||||
public boolean ignoreReturnObject(String typeName,List<String> ignoreParams) {
|
||||
if (JavaClassValidateUtil.isMvcIgnoreParams(typeName,ignoreParams)) {
|
||||
return DocGlobalConstants.MODE_AND_VIEW_FULLY.equals(typeName);
|
||||
}
|
||||
return false;
|
||||
|
@ -198,7 +198,6 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
|||
|
||||
private ApiRequestExample buildReqJson(JavaMethod method, ApiMethodDoc apiMethodDoc, String methodType,
|
||||
ProjectDocConfigBuilder configBuilder) {
|
||||
List<String> ignoreParam = configBuilder.getApiConfig().getIgnoreParam();
|
||||
List<JavaParameter> parameterList = method.getParameters();
|
||||
if (parameterList.size() < 1) {
|
||||
return ApiRequestExample.builder().setUrl(apiMethodDoc.getUrl());
|
||||
|
@ -211,7 +210,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
|||
List<String> springMvcRequestAnnotations = SpringMvcRequestAnnotationsEnum.listSpringMvcRequestAnnotations();
|
||||
List<FormData> formDataList = new ArrayList<>();
|
||||
ApiRequestExample requestExample = ApiRequestExample.builder();
|
||||
Set<String> jsonParamSet = this.jsonParamSet(parameterList,ignoreParam);
|
||||
Set<String> jsonParamSet = this.jsonParamSet(parameterList);
|
||||
out:
|
||||
for (JavaParameter parameter : parameterList) {
|
||||
JavaType javaType = parameter.getType();
|
||||
|
@ -238,7 +237,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
|||
gicTypeName = rewriteClassName;
|
||||
typeName = DocClassUtil.getSimpleName(rewriteClassName);
|
||||
}
|
||||
if (JavaClassValidateUtil.isMvcIgnoreParams(typeName)) {
|
||||
if (JavaClassValidateUtil.isMvcIgnoreParams(typeName,configBuilder.getApiConfig().getIgnoreParam())) {
|
||||
continue;
|
||||
}
|
||||
String simpleTypeName = javaType.getValue().toLowerCase();
|
||||
|
@ -414,7 +413,6 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
|||
|
||||
private List<ApiParam> requestParams(final JavaMethod javaMethod, final String tagName, ProjectDocConfigBuilder builder) {
|
||||
boolean isStrict = builder.getApiConfig().isStrict();
|
||||
List<String> ignoreParam = builder.getApiConfig().getIgnoreParam();
|
||||
Map<String, CustomRespField> responseFieldMap = new HashMap<>();
|
||||
|
||||
Map<String, String> replacementMap = builder.getReplaceClassMap();
|
||||
|
@ -426,7 +424,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
|||
}
|
||||
Map<String, String> constantsMap = builder.getConstantsMap();
|
||||
boolean requestFieldToUnderline = builder.getApiConfig().isRequestFieldToUnderline();
|
||||
Set<String> jsonParamSet = this.jsonParamSet(parameterList,ignoreParam);
|
||||
Set<String> jsonParamSet = this.jsonParamSet(parameterList);
|
||||
List<ApiParam> paramList = new ArrayList<>();
|
||||
int requestBodyCounter = 0;
|
||||
out:
|
||||
|
@ -451,7 +449,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
|||
typeName = rewriteClassName;
|
||||
fullTypeName = DocClassUtil.getSimpleName(rewriteClassName);
|
||||
}
|
||||
if (JavaClassValidateUtil.isMvcIgnoreParams(typeName)) {
|
||||
if (JavaClassValidateUtil.isMvcIgnoreParams(typeName,builder.getApiConfig().getIgnoreParam())) {
|
||||
continue out;
|
||||
}
|
||||
fullTypeName = DocClassUtil.rewriteRequestParam(fullTypeName);
|
||||
|
@ -600,7 +598,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
|||
return false;
|
||||
}
|
||||
|
||||
public Set<String> jsonParamSet(List<JavaParameter> parameterList,List<String> ignoreParams) {
|
||||
public Set<String> jsonParamSet(List<JavaParameter> parameterList) {
|
||||
Set<String> jsonParamSet = new HashSet<>();
|
||||
for (JavaParameter parameter : parameterList) {
|
||||
String paramName = parameter.getName();
|
||||
|
@ -612,9 +610,6 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(CollectionUtil.isNotEmpty(ignoreParams)) {
|
||||
jsonParamSet.addAll(ignoreParams);
|
||||
}
|
||||
return jsonParamSet;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
*/
|
||||
package com.power.doc.utils;
|
||||
|
||||
import com.power.common.util.CollectionUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
|
@ -210,7 +213,10 @@ public class JavaClassValidateUtil {
|
|||
* @param paramType param type name
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isMvcIgnoreParams(String paramType) {
|
||||
public static boolean isMvcIgnoreParams(String paramType,List<String> ignoreParams) {
|
||||
if(CollectionUtil.isNotEmpty(ignoreParams) && ignoreParams.contains(paramType)){
|
||||
return true;
|
||||
}
|
||||
switch (paramType) {
|
||||
case "org.springframework.ui.Model":
|
||||
case "org.springframework.ui.ModelMap":
|
||||
|
|
Loading…
Reference in New Issue