@@ -11,6 +11,31 @@ namespace Microsoft.AspNetCore.Mvc;
1111/// <summary>
1212/// A filter that specifies the type of the value and status code returned by the action.
1313/// </summary>
14+ /// <remarks>
15+ /// This attribute can be used to specify the type of the response body, the status code,
16+ /// and content-type(s) of the response.
17+ ///
18+ /// In an MVC application, this attribute can be applied to an action method or controller class.
19+ /// In a Minimal API application, this attribute should be applied to the delegate method.
20+ ///
21+ /// More than one instance of ProducesResponseTypeAttribute with different status codes may
22+ /// be used to specify multiple possible responses from an endpoint.
23+ /// </remarks>
24+ /// <example>
25+ /// In the following example, the ProducesResponseTypeAttribute is used to specify the type of the
26+ /// response body and the status code for the successful response and the status code, type, and content
27+ /// type for the error response.
28+ /// <code>
29+ /// app.MapGet("/todos/{id}",
30+ /// [ProducesResponseType(typeof(Todo), StatusCodes.Status200OK)]
31+ /// [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound, "application/problem+json")]
32+ /// async (TodoDb db, string id) =>
33+ /// await db.Todos.FindAsync(id)
34+ /// is Todo todo
35+ /// ? Results.Ok(todo)
36+ /// : Results.NotFound());
37+ /// </code>
38+ /// </example>
1439[ AttributeUsage ( AttributeTargets . Class | AttributeTargets . Method , AllowMultiple = true , Inherited = true ) ]
1540public class ProducesResponseTypeAttribute : Attribute , IApiResponseMetadataProvider
1641{
0 commit comments