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

Allow to populate Spring @RequestParam Map<String, String> with request parameter values #43760

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mcruzdev
Copy link
Contributor

@mcruzdev mcruzdev commented Oct 8, 2024

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 using Map<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 inside resteasy-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

  • Should I add the same behavior for pure resteasy resources?
  • Do you have another better solution?
  • What do you think about show a better message on mapping error (@RestQuery Map<String, String> query)?

Any suggestions are welcome!

cc: @geoand

@quarkus-bot quarkus-bot bot added area/rest area/spring Issues relating to the Spring integration labels Oct 8, 2024
@mcruzdev
Copy link
Contributor Author

mcruzdev commented Oct 8, 2024

cc: @cescoffier

@geoand
Copy link
Contributor

geoand commented Oct 8, 2024

Thanks for this!

I will have a look next week when I back from travelling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest area/spring Issues relating to the Spring integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RequestParam Map<String, String> not supported by quarkus-spring
2 participants