Skip to content
This repository was archived by the owner on Dec 4, 2025. It is now read-only.

Commit fabcd5d

Browse files
committed
fix(map<enum,value>): Fix the request parameter is Map<Enum, Value> is not parsed correctly
1. The repair request parameter is Map<Enum, Value>, and enum is not parsed according to the @jsonvalue configuration 2. Fix jsonRequest transfer error Closes #1002
1 parent b53345b commit fabcd5d

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/main/java/com/ly/doc/helper/ParamsBuildHelper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,12 @@ public static List<ApiParam> buildMapParam(String[] globGicName, String pre, int
707707
.orElse(DocGlobalConstants.DEFAULT_MAP_KEY_DESC))
708708
.setVersion(DocGlobalConstants.DEFAULT_VERSION)
709709
.setPid(null == keyParentId ? pid : keyParentId);
710+
711+
Object enumValueWithJsonValue = JavaClassUtil.getEnumValueWithJsonValue(mapKeyClass, projectBuilder,
712+
enumConstant);
713+
if (jsonRequest && enumValueWithJsonValue != null) {
714+
apiParam.setField(pre + enumValueWithJsonValue);
715+
}
710716
apiParam.setId(apiParam.getPid() + paramList.size() + 1);
711717
if (null == keyParentId) {
712718
keyParentId = apiParam.getPid();

src/main/java/com/ly/doc/template/IRestDocTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ else if (JavaClassValidateUtil.isMap(fullyQualifiedName)) {
12471247

12481248
paramList.addAll(ParamsBuildHelper.buildMapParam(gicNameArr, DocGlobalConstants.EMPTY, 0,
12491249
String.valueOf(required), Boolean.FALSE, new HashMap<>(16), builder, groupClasses,
1250-
docJavaMethod.getJsonViewClasses(), 0, Boolean.FALSE, 1, null));
1250+
docJavaMethod.getJsonViewClasses(), 0, jsonRequest, 1, null));
12511251

12521252
// is map without Gic
12531253
if (JavaClassValidateUtil.isMap(typeName)) {

src/main/java/com/ly/doc/utils/JavaClassUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public static Object getDefaultEnumValue(JavaClass javaClass, ProjectDocConfigBu
408408
* @return Object The enum value, whose type depends on the specific enum definition
409409
* @throws RuntimeException If the enum constants do not exist
410410
*/
411-
private static Object getEnumValueWithJsonValue(JavaClass javaClass, ProjectDocConfigBuilder builder,
411+
public static Object getEnumValueWithJsonValue(JavaClass javaClass, ProjectDocConfigBuilder builder,
412412
JavaField enumConstant) {
413413
String methodName = findMethodWithJsonValue(javaClass);
414414
if (Objects.nonNull(methodName)) {

0 commit comments

Comments
 (0)