Skip to content

GenericParameterService#isExplodable method should recognise @ArraySchema as well #984

Closed
@coutin

Description

@coutin

Describe the bug
It seems that sprindoc is not allowing the usage of explode attribute on Parameter, when it s combined with an ArraySchema annotation.

I ve been debugging the issue and spotted that GenericParameterService has a method isExplodable that only supports @Schema annotation, which is not enough in case of Array, because you can't define the items type in the Schema annotation.

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using? 2.4.0
  • What modules and versions of springdoc-openapi are you using? springdoc-openapi-ui 1.5.0
@GetMapping(value = "helloWorld")
@Operation(summary ="helloWorld", description = "helloWorld")
public List<String> helloWorld(
    @Parameter(description = "Dummy list", required = true, explode = Explode.FALSE, , array = @ArraySchema( schema = @Schema(type = "string")), style = ParameterStyle.FORM) @RequestParam(dummyList) List<String> dummyList) { 
   return dummyList; 
} 

Produce parameter like

          {
            "name": "dummyList",
            "in": "query",
            "description": "Dummy list",
            "required": true,
            "style": "form",
            "schema": {
               "type": "array",
               "items": {
                   "type": "string"
               }
            }
          }

Expected behavior
So basically it is expected that @ArraySchema should be treated as @Schema type array, to ensure that array in query parameters are correctly typed in the open api spec.

So it should produce a parameter like :

`Should produce a parameter like :

          {
            "name": "dummyList",
            "in": "query",
            "description": "Dummy list",
            "required": true,
            "style": "form",
            "explode": false,
            "schema": {
               "type": "array",
               "items": {
                   "type": "string"
               }
            }
          }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions