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

RequestParam with map<String,String> doesn't allow the call by SwaggerUI #1947

Closed
potito-coluccelli opened this issue Nov 17, 2022 · 2 comments
Labels
question Further information is requested

Comments

@potito-coluccelli
Copy link

potito-coluccelli commented Nov 17, 2022

Describe the bug
I'm defining a method in a controller class:

@GetMapping("/id")
@Parameter(name = "id1", schema = @Schema(type="string"), required = true)
@Parameter(name = "id2", schema = @Schema(type="string"), required = true)
public MyObject searchById(@RequestParam(required = false) Map<String, String> idMap) {
   //Returns my object
}

It properly generates the swaggerUI interface with the two fields id1 and id2, but clicking on Execute it doesn't send the request.
If I put required=true on @RequestParam it generates a field with a json (required), that it's not what I want, but it still doesn't work.
If I leave @RequestParam(required = false) and i set required=false on the Parameters it send the request, but without the query parameters, so it doesn't work.

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?
    2.7.4

  • What modules and versions of springdoc-openapi are you using?
    org.springdoc:springdoc-openapi-ui:1.6.11
    org.springdoc:springdoc-openapi-webmvc-core:1.6.11

  • What is the actual and the expected result using OpenAPI Description (yml or json)?

The json seems to be ok, the parameters are correctly mapped

  • Provide with a sample code (HelloController) or Test that reproduces the problem:
    @RestController
    @RequestMapping("/hello")
    public class HelloController {
        @GetMapping("/id")
        @Parameter(name = "id1", schema = @Schema(type="string"), required = true)
        @Parameter(name = "id2", schema = @Schema(type="string"), required = true)
        public MyObject searchById(@RequestParam(required = false) Map<String, String> idMap) {
            return idMap.get("id1") + " " + "idMap.get("id2");
        }
    }

Expected behavior

  • A clear and concise description of what you expected to happen.
    I expect that the swaggerUI builds the request correctly with the two query parameters defined
@uc4w6c
Copy link
Collaborator

uc4w6c commented Nov 18, 2022

It seems to be fixed in the latest version. (org.springdoc:springdoc-openapi-ui:1.6.12)
reference #1901

@potito-coluccelli
Copy link
Author

Hi,
You're right I updated the library and it works.
Thank you very much.
Sorry to bother.

@springdoc springdoc locked as resolved and limited conversation to collaborators Nov 18, 2022
@bnasslahsen bnasslahsen added the question Further information is requested label Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants