Skip to content

WithDisplayName() on endpoint not working with ApiDescription with minimal actions #34062

@martincostello

Description

@martincostello

Describe the bug

If a minimal action is configured with a display name, then the configured display name does not flow through to the ApiDescription associated with the action.

To Reproduce

Configure an endpoint action similar to the below:

builder.MapGet("/denied", () => Results.Redirect("/?denied=true"))
       .WithDisplayName("DENIED");

Then inspect the ApiDescription in the debugger, such as with the DocInclusionPredicate() when using AddSwaggerGen():

builder.Services.AddSwaggerGen(options =>
{
    options.SwaggerDoc("v1", new OpenApiInfo { Title = "API", Version = "v1" });
    options.DocInclusionPredicate(
        (_, description) => description.RelativePath?.StartsWith("api/", StringComparison.Ordinal) == true);
});

The ApiDescription.DisplayName property is null.

image

In the above example, the value is expected to be "DENIED".

Further technical details

  • ASP.NET Core 6.0.0-preview.7.21325.3
  • .NET SDK 6.0.100-preview.7.21330.1
  • Visual Studio 2022 17.0.0 Preview 1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: FixedThe bug or enhancement requested in this issue has been checked-in!area-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