Description
Hello,
I am trying to see if it's possible to create rest client interface methods with all the parameters wrapped into a single object instead of multiple parameters.
Scenario:
I have multiple header parameters and non null parameters which i dont want to fill while calling the method everytime.
At current state, the interfaces are defined like this,
@Path("/movies")
public interface MovieReviewService {
@GET
@Path("/{movieId}/reviews/{reviewId}")
Review getReview( @PathParam("movieId") String movieId, @PathParam("reviewId") String reviewId, @HeaderParam apiKey, @HeaderParam logId);
@POST
@Path("/{movieId}/reviews")
String submitReview( @PathParam("movieId") String movieId, Review review, @HeaderParam apiKey, @HeaderParam logId );
}
Here, I would like to populate all header parameters at a common class for ex, RegisterClientHeaders filters or I would like to not pass a value for a particular param.
Expectation:
@Path("/movies")
public interface MovieReviewService {
@GET
@Path("/{movieId}/reviews/{reviewId}")
Review getReview(GetReviewRequest request);
@POST
@Path("/{movieId}/reviews")
String submitReview( SubmitReviewRequest request);
}
class GetReviewRequest {
@PathParam("movieId") String movieId;
@PathParam("reviewId") String reviewId;
@HeaderParam String apiKey;
@HeaderParam String logId;
}
class SubmitReviewRequest {
@PathParam("movieId") String movieId;
@HeaderParam String apiKey;
@HeaderParam String logId;
**Review review;**
}
End result:
I tried wrapping params like this, while the getReview operation works with or without annotated with @BeanParam but submitReview operation doesnt work.
My Observation:
If I unwrap body params from that single object and pass it as another method argument, it works.
Is it by design that we cannot wrap body params into a class along with other params ?
PS: I have tested this using Quarkus / resteasy-reactive implementation.