swagger-ui: Map query parameters are not working as expected.
Given the following definition
  //spring-mvc definition
  @RequestMapping(value = "/category/{id}/map", method = RequestMethod.POST)
  public ResponseEntity<Void> map(@RequestParam Map<String, String> test) {
    return ResponseEntity.ok(null);
  }
   //Jax-rs definition
   @POST
   @Consumes("application/x-www-form-urlencoded")
   public void map(MultivaluedMap<String, String> test) {
     // Store the message
   }
Produces the following spec. The spec is a valid spec for the parameter (test) which is an open ended grab bag of query parameters.
{
   "basePath":"/springfox",
   "host":"localhost:8080",
   "info":{
      "contact":{
         "name":"springfox"
      },
      "description":"",
      "license":{
         "name":"Apache License Version 2.0",
         "url":"https://github.com/springfox/springfox/blob/master/LICENSE"
      },
      "termsOfService":"http://springfox.io",
      "title":"Springfox petstore API",
      "version":"2.0"
   },
   "paths":{
      "/category/{id}/map{?test}":{
         "post":{
            "consumes":[
               "application/json"
            ],
            "operationId":"mapUsingPOST",
            "parameters":[
               {
                  "description":"test",
                  "in":"query",
                  "items":{
                     "additionalProperties":{
                        "type":"string"
                     },
                     "type":"object"
                  },
                  "name":"test",
                  "required":true
               }
            ],
            "produces":[
               "*/*"
            ],
            "responses":{
               "200":{
                  "description":"OK"
               },
            },
            "summary":"map",
            "tags":[
               "category-controller"
            ]
         }
      }
   },
   "swagger":"2.0",
   "tags":[
      {
         "description":"Category Controller",
         "name":"category-controller"
      }
   ]
}
However in swagger-ui, when we load this spec, we see this error
 
NOTE: This error manifests itself in editor.swagger.io as well.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 5
- Comments: 17 (5 by maintainers)
I have the same problem using @ResquestParam with java.util.Map.
Here is the link to the openapi issue for 3.0.
The springfox implementation favors minor spec transgressions over gaps in the documentation especially for common spring usage patterns (and jax-rs patterns). However, I feel the swagger-ui should identify any transgression rather than throw its hands up in the air with an error that is hard to trace or do root cause analysis without stepping through the debugger.
Very soon, in fact, I’d like to this week.