-
Notifications
You must be signed in to change notification settings - Fork 10.7k
API Analyzer doesn't recognize ControllerBase.ValidationProblem. #6061
Copy link
Copy link
Closed
Labels
affected-fewThis issue impacts only small number of customersThis issue impacts only small number of customersanalyzerIndicates an issue which is related to analyzer experienceIndicates an issue which is related to analyzer experiencebugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-openapiinvestigateold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labelsseverity-minorThis label is used by an internal toolThis label is used by an internal tool
Milestone
Metadata
Metadata
Assignees
Labels
affected-fewThis issue impacts only small number of customersThis issue impacts only small number of customersanalyzerIndicates an issue which is related to analyzer experienceIndicates an issue which is related to analyzer experiencebugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-openapiinvestigateold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labelsseverity-minorThis label is used by an internal toolThis label is used by an internal tool
Type
Fields
Give feedbackNo fields configured for issues without a type.
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 forControllerBase.BadRequest().To Reproduce
Steps to reproduce the behavior:
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
ModelStateInvalidFilterusesValidationProblemDetailsto 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 intoControllerBase.BadRequest(ModelState)usingValidationProblemDetailsto build its response object for consistency withModelStateInvalidFilter.