I am new to feign. I have a feign client for a token end point. Apparently we are hitting the /token end point to get the a json string {"token" : "xxxxyyyxxx", "scope": "EPServices","expires-in": "3600"}. I have a pojo class to map these attributes.I want to use feign decoder to do that. How do I do that. The return type of my feign client method is String.
Asked
Active
Viewed 1,044 times
1 Answers
0
If you already have a pojo class eg. TokenResponse
then you directly use it on the feign interface and it will automatically be deserialized into the POJO for you, since Feign has internal decoders to do that for you automatically.
@FeignClient()
public interface TokenClient {
@GetMapping(path = "/token")
TokenResponse getToken();
}
After you get a TokenResponse
you can use a Jackson object mapper or GsonDecoder to convert it to json string if you'd like in another class.
But if you want this all done automatically simply change to this
@FeignClient()
public interface TokenClient {
@GetMapping(path = "/token")
String getToken();
}
and it will be deserialized for you as a json in String.

neshant sharma
- 174
- 2
- 4