quarkus icon indicating copy to clipboard operation
quarkus copied to clipboard

Allow to populate Spring @RestQuery Map<String, String> with request parameter values

Open mcruzdev opened this issue 4 months ago • 13 comments

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

mcruzdev avatar Oct 08 '24 02:10 mcruzdev