Open
Description
My API does some validation on POST/PUT requests on some non-JSONAPI endpoints and may generate an error response using ModelState. When trying to convert these endpoints to JSONAPI, I notice Saule isn't currently trying to use the information available in the ModelState response to provide useful error messages back to the client.
I have a request filter that does the following:
public class InvalidModelStateFilterAttribute : ActionFilterAttribute {
public override void OnActionExecuting(HttpActionContext actionContext) {
if (!actionContext.ModelState.IsValid) {
actionContext.Response = actionContext.Request.CreateErrorResponse(
HttpStatusCode.BadRequest, actionContext.ModelState);
} else {
base.OnActionExecuting(actionContext);
}
}
}
Currently, that gets serialized to something like this:
{"Message":"The request is invalid.","ModelState":{"json.Name":["The category already exists."]}}
With Saule, I'm now getting something like this:
{"errors":[{"title":"The request is invalid."}]}
What would be necessary to change to have this errors
array contain the actual fields and error descriptions?
Metadata
Metadata
Assignees
Labels
No labels