3
votes

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?

1

1 Answers

0
votes

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.