I have some simple controllers that uses .net core model binding for creating an entity using json input.
When sending invalid json (json, that couldn't be parsed correctly because of a typo or missing escape) user will be null and a not usefull error will be thrown.
How could I raise a json validation error and return the information, that json is malformed to the api caller?
[HttpPost]
[ProducesResponseType(typeof(User), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(HttpErrorResponse), StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> Post([FromBody]User user)
{
return Ok(this.userService.CreateNewUser(user));
}