I am using Swagger to generate a Restful API:
@POST
@Consumes({ "application/json" })
@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "Create a task", notes = "", response = Tasks.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "created task", response = Tasks.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "task not found", response = Tasks.class),
@io.swagger.annotations.ApiResponse(code = 200, message = "unexpected error", response = Tasks.class) })
public Response createTask(@ApiParam(value = "The task to create" ,required=true ) NewTask newTask)
throws NotFoundException {
return delegate.createTask(newTask);
}
This API accepts json strings and generates java objects from it. This is working quiet well with one exception: The API accepts any correct formed json string but ignores the content of the json which means i get an object created with default values.
So my question is: How can i validate the incoming jsonstring ( against a json schema) before the actual java object is generated?
public Response createTask(String jsonTask)in the methods parameters afaik but i would prefer to have the object there if its possible.MessageBodyWriter...