Skip to content

PageableHandlerMethodArgumentResolver should resolve Optional<Pageable> arguments #3155

@vhbcm

Description

@vhbcm

I have OpenAPI generated controllers that use Optional for non-required parameters. This results in API like this where, e.g., Pageable is wrapped in the Optional:

    @RequestMapping(
            method = RequestMethod.GET,
            value = "/discovery/agent",
            produces = {"application/json"})
    default ResponseEntity<DiscoveryAgentPageRestDto> _discoveryAgentGet(
            @Parameter(name = "pageable", description = "Defines page number, page size, sort property and order", schema = @Schema(description = "")) @Valid Optional<Pageable> pageable,
            @Parameter(name = "q", description = "Search query", schema = @Schema(description = "")) @Valid @RequestParam(value = "q", required = false) Optional<String> q)
            throws Exception {
        return discoveryAgentGet(pageable, q);
    }

However, the stock Spring Framework PageableHandlerMethodArgumentResolver does not handle this. PageableHandlerMethodArgumentResolver should resolve Optional<Pageable> arguments

Cross reference: spring-projects/spring-framework#17589 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions