Allow to populate Spring @RequestParam Map<String, String> with request parameter values #43760
+264
−21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #43705
What
This pull request allows to populate a
@RequestParam() Map<String, String> queryParams
with the request parameter values, this is aimed to work only for Spring Boot.Current behavior for
@RestQuery
usingMap<String, String>
Actually, when the user aims to use a
Map<String, String>
in the server side with@RestQuery
there is no way to convert the incoming request to the Map<String, String> object, causing an error. You can see more details in here (Behind the scenes spring-web extension converts@RequestParam Map<String, String>
to@RestQuery
).Problems with this draft solution
Problem
We are adding Spring annotation at
independents/resteasy-common
, I think that it is a not good idea because we are adding spring stuff inside resteasy modules (because it I did not add support for Spring MultiValueMap for now).Solution
To have a intermediate annotation like
@QueryMap
insideresteasy-common
for serving as a intermediate indicating that the argument `Map<String, String> should be populated as the request parameter values.The problem with this solution is that the user will be able to add it in a no Spring resource, with pure Java specification.
With this point in mind, I would like to know if it makes sense for us to implement this for pure resteasy resources. If not, would be great to show a better message error to the final user, indicating that use of the annotation is not permitted/not supported.
Questions
@RestQuery Map<String, String> query
)?Any suggestions are welcome!
cc: @geoand