-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Describe the bug
The Web API Analyzer doesn't recognize ControllerBase.ValidationProblem() and does not prompt a codefix to add a [ProducesResponseType] attribute like it does for ControllerBase.BadRequest().
To Reproduce
Steps to reproduce the behavior:
- Using ASP.NET Core 2.2
- Install Microsoft.AspNetCore.Mvc.Api.Analyzers 2.2.0
- Add
return ValidationProblem();to a controller marked with[ApiController].
Expected behavior
Analyzer catches the issue and underlines return ValidationProblem();
Codefix prompt to add appropriate attributes to action.
Additional context
Using ASP.NET Core 2.2 and Microsoft.AspNetCore.Mvc.Api.Analyzers 2.2.0. Since the default ModelStateInvalidFilter uses ValidationProblemDetails to build a 400 response object, it makes sense that people may want to do the same for validation problems within actions so that the response format is consistent in both cases. Alternatively or additionally, there should be a way to opt into ControllerBase.BadRequest(ModelState) using ValidationProblemDetails to build its response object for consistency with ModelStateInvalidFilter.