3

I have a client package where I have defined my REST clients, containing the following interface and models:

@Path("/")
@RegisterRestClient(configKey = "some-api")
public interface SomeRestClient {
    @POST
    @Path("/oauth/token")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    OAuthResult getOAuthToken(OAuthRequest oAuthRequest);

}

and OAuthRequest class:


import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class OAuthRequest {

    private String email;
    private String password;
    @JsonProperty("grant_type")
    private String grantType;
    @JsonProperty("client_id")
    private String clientId;
    @JsonProperty("client_secret")
    private String clientSecret;
}

I import this package into my main service package, but quarkus does not seem to pick up the Jackson annotations. The properties of the request are serialized using camel case, when they should be in snake case.

        @Inject
        @RestClient
        private SomeRestClient someRestClient;
        OAuthRequest oAuthRequest = new OAuthRequest();
        //set fields
        OAuthResult oAuthResult = someRestClient.getOAuthToken(oAuthRequest);

EDIT:

I am using the quarkus-rest-client-jackson and the quarkus-rest-client dependencies, no jsonb dependency anywhere.

I have tried to narrow the problem down: I have moved the client / request classes to my main package, and I have removed the lombok annotations and made my fields which have Jackson annotations public. Still the same problem... Could anyone point me in the right direction of what I am doing wrong?

kiwiidb
  • 331
  • 2
  • 10

1 Answers1

0

Reasteasy is used for your reste endpoint not to access a remote REST service. To access a remote REST service the REST client is used.

The REST client comes with Jackson support of you use the quarkus-rest-client-jackson dependency not the JSON-B one.

loicmathieu
  • 5,181
  • 26
  • 31
  • I was incomplete, I am using the quarkus-rest-client-jackson dependency. – kiwiidb Sep 28 '20 at 12:43
  • If you can provide a small reproducer, you can open an issue on Quarkus github as it seems to be a bug. – loicmathieu Sep 28 '20 at 13:36
  • I have modified the rest-client example from the quickstart guides so it reproduces my issue: https://github.com/kiwiidb/quarkus-quickstarts/commit/da1965d4c41c2d10db3a4a22ecbfcb923752fd4e – kiwiidb Sep 28 '20 at 15:05
  • Your pom.xml include `quarkus-rest-client` and `quarkus-resteasy-jsonb`, I think these will trigger the use of JSONB for the rest client. I suggest to use `quarkus-resteasy-jackson` instead. You cannot use a different serialization layer for your REST endpoint and the REST client. – loicmathieu Sep 29 '20 at 08:56
  • Ok that's correct. Now the reproducer issue does work correctly, but I'm still wondering about my original issue, I don't have any jsonb dependencies there. Will work on a new reproducer issue. – kiwiidb Sep 29 '20 at 09:41
  • Maybe add your full pom.xml or better create a dependency tree to track all dependencies and try to understand what's going one: `mvn dependency:tree`. – loicmathieu Sep 29 '20 at 10:37