Skip to content

Commit 77f69b3

Browse files
authored
Add link to Web API analyzers (#35011)
1 parent 9e31eba commit 77f69b3

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

aspnetcore/fundamentals/openapi/include-metadata.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,9 @@ When not specified by an attribute:
379379
* the schema for the response body of 3xx and 5xx responses is considered to be not specified,
380380
* the content-type for the response body can be inferred from the return type of the action method and the set of output formatters.
381381
382-
Note that there are no compile-time checks to ensure that the response metadata specified with a [`[ProducesResponseType]`](xref:Microsoft.AspNetCore.Mvc.ProducesResponseTypeAttribute) attribute is consistent with the actual behavior of the action method,
383-
which may return a different status code or response body type than specified by the metadata.
382+
By default, there are no compile-time checks to ensure that the response metadata specified with a [`[ProducesResponseType]` attribute](xref:Microsoft.AspNetCore.Mvc.ProducesResponseTypeAttribute) is consistent with the actual behavior of the action method, which may return a different status code or response body type than specified by the metadata. To enable these checks, [enable Web API analyzers](xref:web-api/advanced/analyzers).
384383
385-
In controller-based apps, ASP.NET responds with a ProblemDetails response type when model validation fails or when the action method returns a result with a 4xx or 5xx HTTP status code. Validation errors typically use the 400 status code, so you can use the [`[ProducesResponseType]`](xref:Microsoft.AspNetCore.Mvc.ProducesResponseTypeAttribute) attribute to specify the error response for an action, as shown in the following example:
384+
In controller-based apps, ASP.NET responds with a ProblemDetails response type when model validation fails or when the action method returns a result with a 4xx or 5xx HTTP status code. Validation errors typically use the 400 status code, so you can use the [`[ProducesResponseType]` attribute](xref:Microsoft.AspNetCore.Mvc.ProducesResponseTypeAttribute) to specify the error response for an action, as shown in the following example:
386385
387386
```csharp
388387
[HttpPut("/todos/{id}")]
@@ -541,7 +540,7 @@ public enum DayOfTheWeekAsString
541540
}
542541
```
543542
544-
A special case is when an enum type has the [Flags] attribute, which indicates that the enum can be treated as a bit field; that is, a set of flags. A flags enum with a [JsonConverterAttribute] will be defined as `type: string` in the generated schema with no `enum` property, since the value could be any combination of the enum values. For example, the following enum:
543+
A special case is when an enum type has the `[Flags]` attribute, which indicates that the enum can be treated as a bit field; that is, a set of flags. A flags enum with a `[JsonConverterAttribute]` is defined as `type: string` in the generated schema with no `enum` property, since the value could be any combination of the enum values. For example, the following enum:
545544
546545
```csharp
547546
[Flags, JsonConverter(typeof(JsonStringEnumConverter<PizzaToppings>))]

0 commit comments

Comments
 (0)