Open msmerc opened 3 years ago
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonSubTypes({ @JsonSubTypes.Type(value = Car.class, name = "car"), @JsonSubTypes.Type(value = Lorry.class, name = "lorry") }) public static interface Vehicle { }
I'm trying to get Retrofit to work with polymorphic types, something like this:
Here's my service:
And here's my test:
This gives the following error:
It's struggling to serialize from the interface to the class. The code works fine if I change the API to:
public Call<String> upload(@Body Car vehicle);
, so aCar
can definitely be serialised. But the JacksonConverter seems to struggle with the polymorphism in this instance.I've got a complete Gist for this test here: https://gist.github.com/msmerc/4a53b51200bd1e80ce1e9f7ffe3efb16