1
public interface ItemsClient {
    @RequestLine("POST /items")
    public Map<String, Object> post(Map<String, Object> item);
}

Then

ItemsClient itemsClient = Feign.builder().decoder(new GsonDecoder()).encoder(new GsonEncoder()).target(ItemsClient.class, ROOT_URI);
Map<String, Object> myNewItemWithId = itemsClient.post(myNewItem);

The server send a response with a body like :

{
    "id" : 108171343002018,
    "name" : "myNewItem among many and many !"
}

But then the value of myNewItemWithId.get("id"); is 2147483647, the maximum value of Integer.

Is there a way to tell GsonDecoder to decode the integer numbers into Long ?

Antoine Martin
  • 1,903
  • 2
  • 16
  • 28
  • i don't know about the gsondecoder, but you can always send the id as two integers instead of a long – Thijs Steel Jun 06 '17 at 17:02
  • This seems to be [how gson works](https://stackoverflow.com/a/15508288/6730571). If you want to decode numbers as longs, you need your own structured type, which might not be easy with your object that has "many and many" properties. So, yep, better use another lib such as Jackson as you found out. – Hugues M. Jun 07 '17 at 18:11

1 Answers1

0

It works with the JacksonDecoder.

<dependency>
    <groupId>io.github.openfeign</groupId>
    <artifactId>feign-jackson</artifactId>
    <version>9.0.0</version>
</dependency>
Antoine Martin
  • 1,903
  • 2
  • 16
  • 28