Optimize the generic parameter type, when the generic parameter is the basic type, the type is displayed as the basic type .

This commit is contained in:
shalousun 2021-11-18 00:02:26 +08:00
parent d9a630658d
commit 91b6b87244
2 changed files with 16 additions and 4 deletions

View File

@ -415,7 +415,7 @@ public class JsonBuildHelper {
data0.append(buildJson(simple, gicName, isResp, nextLevel, registryClasses, groupClasses, builder)).append(",");
}
} else {
data0.append("{\"waring\":\"You may have used non-display generics.\"},");
data0.append("{},");
}
} else if (DocGlobalConstants.JAVA_OBJECT_FULLY.equals(subTypeName)) {
if (StringUtil.isNotEmpty(field.getComment())) {
@ -431,10 +431,10 @@ public class JsonBuildHelper {
data0.append(buildJson(simpleName, gicName, isResp, nextLevel, registryClasses, groupClasses, builder)).append(",");
}
} else {
data0.append("{\"waring\":\"You may have used non-display generics.\"},");
data0.append("{},");
}
} else {
data0.append("{\"waring\":\"You may have used non-display generics.\"},");
data0.append("{},");
}
} else if (typeName.equals(subTypeName)) {
data0.append("{\"$ref\":\"...\"}").append(",");

View File

@ -331,7 +331,19 @@ public class ParamsBuildHelper {
String processedType;
if (typeSimpleName.length() == 1) {
processedType = DocClassUtil.processTypeNameForParams(typeSimpleName.toLowerCase());
String gicName = JAVA_OBJECT_FULLY;
if (Objects.nonNull(genericMap.get(typeSimpleName))) {
gicName = genericMap.get(subTypeName);
} else {
if (globGicName.length > 0) {
gicName = globGicName[0];
}
}
if (JavaClassValidateUtil.isPrimitive(gicName)) {
processedType = DocClassUtil.processTypeNameForParams(gicName);
} else {
processedType = DocClassUtil.processTypeNameForParams(typeSimpleName.toLowerCase());
}
} else {
processedType = isShowJavaType ? typeSimpleName : DocClassUtil.processTypeNameForParams(typeSimpleName.toLowerCase());
}