-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Add IgnoreApi() extension method for IEndpointConventionBuilder #34068
Copy link
Copy link
Closed
Labels
Priority:1Work that is critical for the release, but we could probably ship withoutWork that is critical for the release, but we could probably ship withoutapi-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
Metadata
Metadata
Assignees
Labels
Priority:1Work that is critical for the release, but we could probably ship withoutWork that is critical for the release, but we could probably ship withoutapi-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
Type
Fields
Give feedbackNo fields configured for issues without a type.
Background and Motivation
Related to #34061, if using minimal hosting with minimal actions and Swashbuckle and it is possible to hide actions from API Explorer using the
[ApiExplorerSettings]attribute (which doesn't work right now, see also #34065), it would be a quality-of-life improvement to the API surface to add an extension method forIEndpointConventionBuilderto make it require less verbose code to hide it.Proposed API
Add a new extension method to the
Microsoft.AspNetCore.Mvc.ApiExplorerassembly with a name something along the lines ofIgnoreApi():namespace Microsoft.AspNetCore.Builder { + public static class ApiExplorerEndpointConventionBuilderExtensions + { + public static TBuilder IgnoreApi<TBuilder>(this TBuilder builder) where TBuilder : IEndpointConventionBuilder; + } }The implementation would be something like this:
Usage Examples
Alternative Designs
No alternative designs considered, this is just API sugar to remove the need to use verbose way of doing this using the existing APIs, similar to the existing
AllowAnonymous(),RequireAuthorization(),RequireCors(),RequireHost()andWithDisplayName()extension methods:Risks
None that I'm aware of, other than potential conflicts with user-defined application extension methods of the same name.