I have the following REST service that receives a POJO/Bean as a parameter but it's name in the Bean Validation JSON response is presented as arg0
.
How can I give it a custom name like "request"?
REST Service
@Path("/service")
public class MyRequestResource {
@POST
public void post(@Valid MyRequest request) {
/* do stuff here */
}
}
The POJO/Bean (@BeanParam
if you will)
public class MyRequest {
@NotNull
private LocalDate date;
}
Bean Validation response
As we can see the response JSON is returning "arg0" as the name of the bean param. How can I change the name for something custom like "request"?
{
"exception": null,
"fieldViolations": [],
"propertyViolations": [],
"classViolations": [],
"parameterViolations": [
{
"constraintType": "PARAMETER",
"path": "post.arg0.date",
"message": "may not be null",
"value": ""
}
],
"returnValueViolations": []
}