From 95157c5035cc01a12dd39502ce6ec7626bba147f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Vav=C5=99=C3=ADk?= Date: Thu, 16 Jun 2022 19:13:07 +0200 Subject: [PATCH] Document Reactive Rest Client support of dynamic query parameters Documents: [24783](https://github.com/quarkusio/quarkus/pull/24783) Reactive Rest Client sending query paramters passed as a `Map`, however I can't see this in documentation. There should be at least reference to this feature. --- .../main/asciidoc/rest-client-reactive.adoc | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/docs/src/main/asciidoc/rest-client-reactive.adoc b/docs/src/main/asciidoc/rest-client-reactive.adoc index dbf183349b513..59507ab852d88 100644 --- a/docs/src/main/asciidoc/rest-client-reactive.adoc +++ b/docs/src/main/asciidoc/rest-client-reactive.adoc @@ -134,6 +134,48 @@ The `getById` method above is a blocking call. It should not be invoked on the e The <> section describes how to make non-blocking calls. ==== +=== Query Parameters + +The easiest way to specify a query parameter is to annotate a client method parameter with the `@QueryParam` or the `@RestQuery`. +The `@RestQuery` is equivalent of the `@QueryParam`, but with optional name. Additionally, it can be also used to pass query parameters +as a `Map`, which is convenient if parameters are not known in advance. + +[source, java] +---- +package org.acme.rest.client; + +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; +import org.jboss.resteasy.reactive.RestQuery; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MultivaluedMap; +import java.util.Map; +import java.util.Set; + +@Path("/extensions") +@RegisterRestClient(configKey = "extensions-api") +public interface ExtensionsService { + + @GET + Set getById(@QueryParam("id") Integer id); + + @GET + Set getByName(@RestQuery String name); <1> + + @GET + Set getByFilter(@RestQuery Map filter); <2> + + @GET + Set getByFilters(@RestQuery MultivaluedMap filters); <3> + +} +---- +<1> Request query will include parameter with key `name` +<2> Each `Map` entry represents exactly one query parameter +<3> `MultivaluedMap` allows you to send array values + === Path Parameters If the GET request requires path parameters you can leverage the `@PathParam("parameter-name")` annotation instead of