Skip to content

[Minimal API] Route, Query and Header parameter names are ignored when using WithOpenApi extension method #45542

@marcominerva

Description

@marcominerva

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Let's consider the following endpoint, in which every argument has been renamed with the corresponding attribute:

app.MapGet("/api/{id:guid}/search", ([FromRoute(Name = "id")] Guid searchId, 
    [FromQuery(Name = "q")] string searchText, [FromHeader(Name = "x-version")] string version) =>
{
    return TypedResults.NoContent();
});

Resulting OpenAPI documentation will show the correct names:

image

However, if I just add the WithOpenApi extension method, then parameter names are ignored, so the generated documentation will become incorrect:

image

Expected Behavior

Parameter names should be taken into account even when using the WithOpenApi extension method.

Steps To Reproduce

Minimal repro here: https://github.com/marcominerva/ParameterRenameIssue.

Exceptions (if any)

No response

.NET Version

7.0.100

Anything else?

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions