support short annotation name

This commit is contained in:
oppofind 2019-12-20 23:28:44 +08:00
parent a648962b39
commit 59007f8ac6
2 changed files with 32 additions and 2 deletions

View File

@ -992,6 +992,7 @@ public class SourceBuilder {
}
boolean containsBrace = apiMethodDoc.getUrl().replace(DEFAULT_SERVER_URL, "").contains("{");
Map<String, String> paramsMap = new LinkedHashMap<>();
List<String> springMvcRequestAnnotations = SpringMvcRequestAnnotations.listSpringMvcRequestAnnotations();
for (JavaParameter parameter : parameterList) {
JavaType javaType = parameter.getType();
String simpleTypeName = javaType.getValue();
@ -1010,8 +1011,8 @@ public class SourceBuilder {
String defaultVal = null;
boolean notHasRequestParams = true;
for (JavaAnnotation annotation : annotations) {
String fullName = annotation.getType().getFullyQualifiedName();
if (!fullName.contains(DocGlobalConstants.SPRING_WEB_ANNOTATION_PACKAGE)) {
String fullName = annotation.getType().getSimpleName();
if (!springMvcRequestAnnotations.contains(fullName)) {
continue;
}
String annotationName = annotation.getType().getSimpleName();

View File

@ -0,0 +1,29 @@
package com.power.doc.constants;
import java.util.ArrayList;
import java.util.List;
/**
* @author yu 2019/12/20.
*/
public enum SpringMvcRequestAnnotations {
PATH_VARIABLE("PathVariable"),
REQ_PARAM ("RequestParam"),
REQUEST_BODY("RequestBody"),
REQUEST_HERDER ("RequestHeader"),
;
private String value;
SpringMvcRequestAnnotations(String value) {
this.value = value;
}
public static List<String> listSpringMvcRequestAnnotations() {
List<String> annotations = new ArrayList<>();
for (SpringMvcRequestAnnotations annotation : SpringMvcRequestAnnotations.values()) {
annotations.add(annotation.value);
}
return annotations;
}
}