修改请求参数不显示问题,兼容validator常用注解

This commit is contained in:
chenzhe 2019-12-16 14:09:46 +08:00
parent 604ec47b85
commit 4b39a18f12
2 changed files with 70 additions and 7 deletions

View File

@ -4,10 +4,7 @@ import com.power.common.util.CollectionUtil;
import com.power.common.util.JsonFormatUtil;
import com.power.common.util.StringUtil;
import com.power.common.util.UrlUtil;
import com.power.doc.constants.DocAnnotationConstants;
import com.power.doc.constants.DocGlobalConstants;
import com.power.doc.constants.DocTags;
import com.power.doc.constants.Methods;
import com.power.doc.constants.*;
import com.power.doc.model.*;
import com.power.doc.utils.DocClassUtil;
import com.power.doc.utils.DocUtil;
@ -186,7 +183,7 @@ public class SourceBuilder {
apiNoteValue = method.getComment();
}
String authorValue = DocUtil.getNormalTagComments(method, DocTags.AUTHOR, cls.getName());
if(this.isShowAuthor && StringUtil.isNotEmpty(authorValue)){
if (this.isShowAuthor && StringUtil.isNotEmpty(authorValue)) {
apiMethodDoc.setAuthor(authorValue);
}
apiMethodDoc.setDetail(apiNoteValue);
@ -1213,8 +1210,10 @@ public class SourceBuilder {
}
requestBodyCounter++;
} else {
List<String> validatorAnnotations = DocValidatorAnnotations.listValidatorAnnotations();
if (REQUEST_PARAM.equals(annotationName) ||
DocAnnotationConstants.SHORT_PATH_VARIABLE.equals(annotationName)) {
DocAnnotationConstants.SHORT_PATH_VARIABLE.equals(annotationName)
|| validatorAnnotations.contains(annotationName)) {
AnnotationValue annotationValue = annotation.getProperty(DocAnnotationConstants.VALUE_PROP);
if (null != annotationValue) {
paramName = StringUtil.removeQuotes(annotationValue.toString());
@ -1295,7 +1294,7 @@ public class SourceBuilder {
|| DocAnnotationConstants.SHORT_REST_CONTROLLER.equals(annotationName)
|| DocGlobalConstants.REST_CONTROLLER_FULLY.equals(annotationName)
|| DocGlobalConstants.CONTROLLER_FULLY.equals(annotationName)
) {
) {
return true;
}
}

View File

@ -0,0 +1,64 @@
package com.power.doc.constants;
import java.util.ArrayList;
import java.util.List;
/**
* spring validator annotations
*
* @author yu 2019/9/19.
*/
public enum DocValidatorAnnotations {
NOT_EMPTY("NotEmpty"),
NOT_BLANK("NotBlank"),
NOT_NULL("NotNull"),
NULL("Null"),
ASSERT_TRUE("AssertTrue"),
ASSERT_FALSE("AssertFalse"),
MIN("Min"),
MAX("Max"),
DECIMAL_MIN("DecimalMin"),
DECIMAL_MAX("DecimalMax"),
SIZE("Size"),
DIGITS("Digits"),
PAST("Past"),
FUTURE("Future"),
PATTERN("Pattern"),
EMAIL("Email"),
LENGTH("Length"),
RANGE("Range");
private String value;
DocValidatorAnnotations(String value) {
this.value = value;
}
public static List<String> listValidatorAnnotations() {
List<String> annotations = new ArrayList<>();
for (DocValidatorAnnotations annotation : DocValidatorAnnotations.values()) {
annotations.add(annotation.value);
}
return annotations;
}
}