Skip to content

Add support for setting ApiDescriptor.GroupName for minimal APIs #34443

@DamianEdwards

Description

@DamianEdwards

Minimal APIs currently don't populate any value for the ApiDescriptor.GroupName property. We should add support for setting the group name via endpoint metadata and flowing that through to the ApiDescriptor, e.g.:

app.MapGet("/myapi/do-the-thing", () => "done!")
   .WithGroupName("v1");

// Psuedo-spec
public static IEndpointConventionBuilder WithGroupName(this IEndpointConventionBuilder builder, string groupName)
{
    builder.WithMetadata(new EndpointGroupNameMetadata(groupName));
}

// Attribute for declarative scenario
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Delegate, Inherited = false, AllowMultiple = false)]
public sealed class EndpointGroupNameAttribute: Attribute, IEndpointGroupNameMetadata;

Setting it by default
Swashbuckle currently uses ApiDescriptor.GroupName in its default API inclusion predicate in such a way that if we were to set a default value that doesn't match the configured Swagger document name, the APIs would not be included by default. For that reason it seems like we shouldn't set a default value for ApiDescriptor.GroupName unless we also update the Swashbuckle logic.

@bradygaster

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:1Work that is critical for the release, but we could probably ship withoutapi-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-minimal-actionsController-like actions for endpoint routing

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions