Hi!
My entity look like
public class Consumption{
private int id;
private double quantity;
private double distance;
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public Consumption(@JsonProperty(value = "quantity", required = true)double quantity,
@JsonProperty(value = "distance", required = true)double distance,
@JsonProperty(value = "vehicle", required = false)Vehicle vehicle) {...
And REST method:
@POST
@Path("/setConsumption/")
public Response setConsumption(@Valid Consumption consum){...
When I receive JSON like below, everything is ok:
{"vehicle":{"id":1},"distance":1000,"quantity":2000}
But when i receive JSON like:
{"vehicle":{"id":1},"quantity":2000}
I get exception in JSON:
Missing required creator property 'distance' (index 1) at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@1b72cb6; line: 1, column: 181]
Is there a way how to override this exception message and return it as custom JSON format, which could client parser understand?
As I have been testing, validation does not reach my REST POST "setConsumption/" method.
Thanks.
Have a nice day, T.