Skip to content

Default value for List/Array RequestParameter has wrong type #1015

Closed
@tkalmar

Description

@tkalmar

Describe the bug
Given the following Controller Method

  @Operation(description = "Test-Swagger")
  @GetMapping("/test/")
  @ApiResponse(responseCode = "204", description = "No content")
  @ResponseStatus(value = HttpStatus.NO_CONTENT)
  public void test(@RequestParam(defaultValue = "users,123") List<String> values) {
   ...
  }

the following default is generated;

"default":"users,123"

This is a violation of the OAS3.0

default - The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided. Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. For example, if type is string, then default can be "foo" but cannot be 1.

so i think the correct value would be

"default": ["users","123"]

To Reproduce
Steps to reproduce the behavior:
Spring boot: 2.4.1
SpringDoc: 1.5.2
Expected behavior
set the correct type for the default value

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions