@@ -10,9 +10,33 @@ namespace Microsoft.AspNetCore.Mvc;
1010/// Specifies that a parameter or property should be bound using the request body.
1111/// </summary>
1212/// <remarks>
13+ /// Binds a parameter or property to the request body.
14+ ///
1315/// By default, ASP.NET Core MVC delegates the responsibility of reading the body to an input formatter.<br/>
1416/// In the case of ASP.NET Core Minimal APIs, the body is deserialized by <see cref="System.Text.Json.JsonSerializer"/>.
17+ ///
18+ /// For more information about parameter binding see
19+ /// <see href="https://learn.microsoft.com/aspnet/core/fundamentals/minimal-apis/parameter-binding">Parameter binding</see>.
1520/// </remarks>
21+ /// <example>
22+ /// In this example, the value of the 'name' field in the form-data request body is bound to the name parameter,
23+ /// and the value of the 'age' field is bound to the age parameter.
24+ /// <code>
25+ /// app.MapPost("/from-body", ([FromBody] Person person) => person);
26+ ///
27+ /// public record Person(string Name, int Age);
28+ /// </code>
29+ ///
30+ /// If the EmptyBodyBehavior is set to EmptyBodyBehavior.Allow in the FromBody attribute,
31+ /// requests without a request body are allowed.
32+ /// <code>
33+ /// app.MapPost("/allow-empty-body",
34+ /// (
35+ /// [Description("An optional request body")]
36+ /// [FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] Body body
37+ /// ) =>
38+ /// </code>
39+ /// </example>
1640[ AttributeUsage ( AttributeTargets . Parameter | AttributeTargets . Property , AllowMultiple = false , Inherited = true ) ]
1741public class FromBodyAttribute : Attribute , IBindingSourceMetadata , IConfigureEmptyBodyBehavior , IFromBodyMetadata
1842{
0 commit comments