-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Closed
Copy link
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-minimal-actionsController-like actions for endpoint routingController-like actions for endpoint routingold-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 labels
Milestone
Description
Background and Motivation
1. Minimal APIs should be able to add their own ConsumesRequestTypeAttribute
to their endpoint metadata, either by decorating the method/lambda with the ConsumesRequestTypeAttribute
, or via new Accepts(string contentType
) or Accepts<TRequest>(string contentType)
methods on MinimalActionEndpointConventionBuilder
. This should override any consumes metadata that was added via the 1st proposal (i.e. the 1st proposal is likely implemented as fallback logic in the endpoint builder).
ApiExplorer
should be updated to add aApiParameterDescription
to theApiDescription
to represent the incoming request body based on the details in the endpoint'sIApiRequestMetadataProvider
metadata if present.
Proposed API
namespace Microsoft.AspNetCore.Http
{
public static class OpenApiEndpointConventionBuilderExtensions
{
+ public static DelegateEndpointConventionBuilder Accepts<TRequest>(this DelegateEndpointConventionBuilder
+ builder, string contentType, params string[] additionalContentTypes) where TRequest : notnull
}
}
Usage Examples
app.MapPost("/create-todo", (Todo todo) => $"{todo.Name}").Accepts<Todo>("application/xml");
Risks
very low.
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-minimal-actionsController-like actions for endpoint routingController-like actions for endpoint routingold-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 labels