Skip to content

Support optional @QueryParam on Rest client #42623

@diversit

Description

@diversit

Description

The Quarkus Rest client does not seem to support @QueryParam arguments which are of type java.util.Optional or io.vavr.control.Option.

Using an argument like @QueryParam("type") Optional<String> or @QueryParam("type") Option<String> creates a url like http://myhost/endpoint?type=Optional%5Btype%5D or http://myhost/endpoint?type=Some%28type%29.
Or with ?type=Optional.empty or ?type=None when no value is provided.

Currently the only option to have optional query parameters seems to be to use a @RestQuery Map<String, String> queryParams argument.
This however do not give a strict control on which query parameters are allowed.

It would therefore be nice to support Optional and/or Option argument to have a better typed and documented Rest client function.

Implementation ideas

Support java.util.Optional as @QueryParam arguments.
When a value is provided, add it to the query parameters.
When no value is provided, do not add it to the query parameters.

And it would be awesome when also Vavr's io.vavr.control.Option could be supported.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions