I am writing a REST client using Feign. There is an endpoint which can be generalized by parameterizing the path. But based on the path I can get a different type of response.
So I am trying to use a single method using generic. Since I must tell the method on the return type, I am parameterizing the type of the return value, like below,
@RequestLine("GET /objects/{type}/{model_id}")
public <T> Entity<T> getObject(
@Param("type") String theObjectType, @Param("model_id") String theModelId,
Class<T> theResponseClass);
But the problem is, Feign will use theResponseClass
as body.
How can I achieve a generic feign client method?