0

EDIT: Problem was quarkus-rest-client-reactive, see my answer.

From my understanding of the MicroProfile REST Client available in Quarkus, I should be able to define sub-resources in my REST client interface that will allow me to nest resources under each other like so.

package org.acme.example

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

@RegisterRestClient
@Path("/api/foo")
public interface FoosService {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    Uni<List<Foo>> getAll();

    @Path("/{id}")
    FooService foo(@PathParam("id") String id);
}

public interface FooService {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    Uni<Foo> toRepresentation();
}

However, when I inject and call the client interface in my code, it throws a AbstractMethodError on the client.foo("bar").toRepresentation() call.

@Path("/bar")
public class BarResource {
    @RestClient
    FoosResource client;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Foo getBar() {
        return client.foo("bar").toRepresentation();
    }
}

All my research into this seems to suggest that this is possible, but there are no specific examples for Quarkus that show client sub-resources.

Adam J
  • 1
  • 1
  • @LucaBassoRicci [Keycloak Admin API Client](https://github.com/keycloak/keycloak/tree/master/integration/admin-client) is a good example of a RESTEasy Client using the Client Proxy Framework that includes sub-resources (granted the RESTEasy version in that client is 3.13.2, while the latest Quarkus version uses 4.6.1, but none of the RESTEasy changelogs mention any change in the relevant behaviour.) – Adam J Jul 27 '21 at 04:20
  • I assume that you have copy-paste error but both interfaces are named FooService – Javier Toja Jul 27 '21 at 07:49
  • did you figure it out? – lordvlad Dec 08 '21 at 22:46

2 Answers2

0

Something that I failed to mention in the original post was that I was using the Reactive extension for the REST Client, which appears to cause the issue.

Using the synchronous extension allows the proxy to correctly build sub-resource proxies. There is probably more configuration that needs to be set for the reactive version to work with sub-resources.

Adam J
  • 1
  • 1
0

Subresources in general work with Quarkus Rest Client Reactive. You can take a look at the test we have in the Quarkus codebase for an example (one problem is that it most probably uses more features than you need): https://github.com/quarkusio/quarkus/blob/2.1.0.Final/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/subresource/SubResourceTest.java#L28

I don't see anything particularly wrong with your code sample. If you could create a GitHub issue in https://github.com/quarkusio/quarkus/issues with a minimal reproducer of your problem, that would help me a lot in either fixing it or helping you.

  • got an reproducer for the same issue with sub-sub-resources here: https://github.com/lordvlad/quarkus/compare/2.5.1.Final...lordvlad:subsubresource-bug-reproducer?expand=1; I also tried to annotate the `SubClient` with `@Path("/")` and `@RegisterRestClient`, neither of which helped – lordvlad Dec 09 '21 at 01:15