repair gitee issues #I1426C

This commit is contained in:
songhaozhi 2019-10-28 22:28:21 +08:00
parent 9d7f53731a
commit 765876b2d0
1 changed files with 31 additions and 33 deletions

View File

@ -46,7 +46,6 @@ public class SourceBuilder {
private static final String NO_COMMENTS_FOUND = "No comments found.";
private static final String METHOD_DESCRIPTION = "apiNote";
private Map<String, JavaClass> javaFilesMap = new HashMap<>();
@ -227,11 +226,12 @@ public class SourceBuilder {
String className = method.getDeclaringClass().getCanonicalName();
Map<String, String> paramMap = DocUtil.getParamsComments(method, DocTags.PARAM, className);
String paramName = javaParameter.getName();
ApiReqHeader apiReqHeader;
for (JavaAnnotation annotation : javaAnnotations) {
String annotationName = annotation.getType().getName();
if (REQUEST_HERDER.equals(annotationName)) {
ApiReqHeader apiReqHeader = new ApiReqHeader();
apiReqHeader = new ApiReqHeader();
Map<String, Object> requestHeaderMap = annotation.getNamedParameterMap();
if (requestHeaderMap.get(DocAnnotationConstants.VALUE_PROP) != null) {
apiReqHeader.setName(StringUtil.removeQuotes((String) requestHeaderMap.get(DocAnnotationConstants.VALUE_PROP)));
@ -1077,43 +1077,41 @@ public class SourceBuilder {
comment = NO_COMMENTS_FOUND;
}
List<JavaAnnotation> annotations = parameter.getAnnotations();
if (annotations.size() == 0) {
//default set required is true
if (DocClassUtil.isCollection(fullTypeName) || DocClassUtil.isArray(fullTypeName)) {
String[] gicNameArr = DocClassUtil.getSimpleGicName(typeName);
String gicName = gicNameArr[0];
if (DocClassUtil.isArray(gicName)) {
gicName = gicName.substring(0, gicName.indexOf("["));
}
String typeTemp = "";
if (DocClassUtil.isPrimitive(gicName)) {
typeTemp = " of " + DocClassUtil.processTypeNameForParams(gicName);
ApiParam param = ApiParam.of().setField(paramName)
.setType(DocClassUtil.processTypeNameForParams(simpleName) + typeTemp)
.setDesc(comment).setRequired(true).setVersion(DocGlobalConstants.DEFAULT_VERSION);
paramList.add(param);
} else {
ApiParam param = ApiParam.of().setField(paramName)
.setType(DocClassUtil.processTypeNameForParams(simpleName) + typeTemp)
.setDesc(comment).setRequired(true).setVersion(DocGlobalConstants.DEFAULT_VERSION);
paramList.add(param);
paramList.addAll(buildParams(gicNameArr[0], "└─", 1, "true", responseFieldMap, false, false));
}
} else if (DocClassUtil.isPrimitive(simpleName)) {
//default set required is true
if (DocClassUtil.isCollection(fullTypeName) || DocClassUtil.isArray(fullTypeName)) {
String[] gicNameArr = DocClassUtil.getSimpleGicName(typeName);
String gicName = gicNameArr[0];
if (DocClassUtil.isArray(gicName)) {
gicName = gicName.substring(0, gicName.indexOf("["));
}
String typeTemp = "";
if (DocClassUtil.isPrimitive(gicName)) {
typeTemp = " of " + DocClassUtil.processTypeNameForParams(gicName);
ApiParam param = ApiParam.of().setField(paramName)
.setType(DocClassUtil.processTypeNameForParams(simpleName))
.setType(DocClassUtil.processTypeNameForParams(simpleName) + typeTemp)
.setDesc(comment).setRequired(true).setVersion(DocGlobalConstants.DEFAULT_VERSION);
paramList.add(param);
} else if (DocGlobalConstants.JAVA_MAP_FULLY.equals(typeName)) {
ApiParam param = ApiParam.of().setField(paramName)
.setType("map").setDesc(comment).setRequired(true).setVersion(DocGlobalConstants.DEFAULT_VERSION);
paramList.add(param);
} else {
paramList.addAll(buildParams(fullTypeName, "", 0, "true", responseFieldMap, false, false));
ApiParam param = ApiParam.of().setField(paramName)
.setType(DocClassUtil.processTypeNameForParams(simpleName) + typeTemp)
.setDesc(comment).setRequired(true).setVersion(DocGlobalConstants.DEFAULT_VERSION);
paramList.add(param);
paramList.addAll(buildParams(gicNameArr[0], "└─", 1, "true", responseFieldMap, false, false));
}
} else if (DocClassUtil.isPrimitive(simpleName)) {
ApiParam param = ApiParam.of().setField(paramName)
.setType(DocClassUtil.processTypeNameForParams(simpleName))
.setDesc(comment).setRequired(true).setVersion(DocGlobalConstants.DEFAULT_VERSION);
paramList.add(param);
} else if (DocGlobalConstants.JAVA_MAP_FULLY.equals(typeName)) {
ApiParam param = ApiParam.of().setField(paramName)
.setType("map").setDesc(comment).setRequired(true).setVersion(DocGlobalConstants.DEFAULT_VERSION);
paramList.add(param);
} else {
paramList.addAll(buildParams(fullTypeName, "", 0, "true", responseFieldMap, false, false));
}
for (JavaAnnotation annotation : annotations) {
String required = "true";
AnnotationValue annotationRequired = annotation.getProperty(DocAnnotationConstants.REQUIRED_PROP);
@ -1229,7 +1227,7 @@ public class SourceBuilder {
|| DocAnnotationConstants.SHORT_REST_CONTROLLER.equals(annotationName)
|| DocGlobalConstants.REST_CONTROLLER_FULLY.equals(annotationName)
|| DocGlobalConstants.CONTROLLER_FULLY.equals(annotationName)
) {
) {
return true;
}
}