Skip to content

Wrong Parameter Name with Default Sort #1010

Closed
@tkalmar

Description

@tkalmar

Describe the bug
When a controller Pageable method parameter is annotated with @PageableDefault and a sort Parameter is given in the annotation the parameter name for the sort is not sort. Instead it is the value of the sort Parameter.
The cause is:

if (pageableDefault != null && ArrayUtils.isNotEmpty(pageableDefault.sort()))
name = String.join(",", pageableDefault.sort());

To Reproduce
Following Controller Method triggers the bug

  @Operation(description = "SomeDescription")
  @GetMapping("/")
  public String getPatientList(@PageableDefault(size = 100, sort = { "someField" }, direction = Sort.Direction.ASC)
                                            @ParameterObject
                                            Pageable pageable){
return "bla";
}

leads to:

{
            "name": "someField",
            "in": "query",
            "description": "Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }

Expected behavior
the field name should stay sort the default value should be someField,asc (notice value + sort direction)
The only time the field name should be changed, is when annotated with @Qualifier which seems also not supported.

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