From 91b6b87244603e8600e73bfa28dbe03355097a52 Mon Sep 17 00:00:00 2001 From: shalousun Date: Thu, 18 Nov 2021 00:02:26 +0800 Subject: [PATCH] Optimize the generic parameter type, when the generic parameter is the basic type, the type is displayed as the basic type . --- .../java/com/power/doc/helper/JsonBuildHelper.java | 6 +++--- .../com/power/doc/helper/ParamsBuildHelper.java | 14 +++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/power/doc/helper/JsonBuildHelper.java b/src/main/java/com/power/doc/helper/JsonBuildHelper.java index 75baae0..1127198 100644 --- a/src/main/java/com/power/doc/helper/JsonBuildHelper.java +++ b/src/main/java/com/power/doc/helper/JsonBuildHelper.java @@ -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(","); diff --git a/src/main/java/com/power/doc/helper/ParamsBuildHelper.java b/src/main/java/com/power/doc/helper/ParamsBuildHelper.java index 72524c8..db98d8c 100644 --- a/src/main/java/com/power/doc/helper/ParamsBuildHelper.java +++ b/src/main/java/com/power/doc/helper/ParamsBuildHelper.java @@ -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()); }