Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the request parameter is Map<Enum, Value> is not parsed correctly #1003

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/com/ly/doc/helper/ParamsBuildHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,12 @@ public static List<ApiParam> buildMapParam(String[] globGicName, String pre, int
.orElse(DocGlobalConstants.DEFAULT_MAP_KEY_DESC))
.setVersion(DocGlobalConstants.DEFAULT_VERSION)
.setPid(null == keyParentId ? pid : keyParentId);

Object enumValueWithJsonValue = JavaClassUtil.getEnumValueWithJsonValue(mapKeyClass, projectBuilder,
enumConstant);
if (jsonRequest && enumValueWithJsonValue != null) {
apiParam.setField(pre + enumValueWithJsonValue);
}
apiParam.setId(apiParam.getPid() + paramList.size() + 1);
if (null == keyParentId) {
keyParentId = apiParam.getPid();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ly/doc/template/IRestDocTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ else if (JavaClassValidateUtil.isMap(fullyQualifiedName)) {

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

// is map without Gic
if (JavaClassValidateUtil.isMap(typeName)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ly/doc/utils/JavaClassUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public static Object getDefaultEnumValue(JavaClass javaClass, ProjectDocConfigBu
* @return Object The enum value, whose type depends on the specific enum definition
* @throws RuntimeException If the enum constants do not exist
*/
private static Object getEnumValueWithJsonValue(JavaClass javaClass, ProjectDocConfigBuilder builder,
public static Object getEnumValueWithJsonValue(JavaClass javaClass, ProjectDocConfigBuilder builder,
JavaField enumConstant) {
String methodName = findMethodWithJsonValue(javaClass);
if (Objects.nonNull(methodName)) {
Expand Down
Loading