In Quarkus, I expose a PUT method that allows to modify an Animal, which can be a Dog or a Cat
Here is the method signature I want to have:
@PUT
@Path("{id}")
public Response updateAnimal(@PathParam Long id, Animal animal) {}
I want the frontend to send a Dog or a Cat, that would be deserialized as an Animal inside Quarkus. But when the frontend sends a Dog or a Cat, i get this error:
SEVERE [org.ecl.yas.int.Unmarshaller] (executor-thread-199) Can't create instance
The frontend sends a json object with all the attributes of a Dog or a Cat, and I am pretty sure Quarkus doesn't manage to transform the json into a supertype object.
public abstract class Animal {
private String name;
...
}
public class Dog extends Animal {
private String dogAttribute;
...
}
public class Cat extends Animal {
private String catAttriute;
}
Example of json sent by the frontend in the body:
{
"name": "toto",
"dogAttribute": "dog"
}