Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support optional @QueryParam on Rest client #42623

Closed
diversit opened this issue Aug 19, 2024 · 4 comments · Fixed by #45672
Closed

Support optional @QueryParam on Rest client #42623

diversit opened this issue Aug 19, 2024 · 4 comments · Fixed by #45672
Labels
Milestone

Comments

@diversit
Copy link

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.

@diversit diversit added the kind/enhancement New feature or request label Aug 19, 2024
Copy link

quarkus-bot bot commented Aug 19, 2024

/cc @cescoffier (rest-client), @geoand (rest-client)

@geoand
Copy link
Contributor

geoand commented Aug 26, 2024

We can definitely support Optional, but I am afraid we that we are not going to introduce any kind of support for Vavr.

@lasteris
Copy link
Contributor

lasteris commented Jan 15, 2025

We can definitely support Optional

Can i try to investigate this ? java.util.Optional for QueryParam / RestQuery (if it doesn't support either)

@geoand
Copy link
Contributor

geoand commented Jan 15, 2025

By all means :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants