-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
The following unit test fails because the parameters are null
.
[Fact]
public async Task SupportsUnusedRouteParametersFromMinimalApis()
{
var source = """
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
var builder = WebApplication.CreateBuilder();
builder.Services.AddOpenApi();
var app = builder.Build();
app.MapGet("/{userId}", RouteHandlerExtensionMethods.Get);
app.Run();
public static class RouteHandlerExtensionMethods
{
/// <param name="userId">The id of the user.</param>
public static string Get()
{
return "Hello, World!";
}
}
""";
var generator = new XmlCommentGenerator();
await SnapshotTestHelper.Verify(source, generator, out var compilation);
await SnapshotTestHelper.VerifyOpenApi(compilation, document =>
{
var path = document.Paths["/{userId}"].Operations[HttpMethod.Get];
Assert.NotEmpty(path.Parameters);
Assert.Equal("The id of the user.", path.Parameters[0].Description);
});
}
Expected Behavior
The unused path parameter {userId}
should be emitted on the operation or on the path as a parameter (that is document.Paths["/{userId}"].Parameters
).
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
10.0.100-rc.1.25420.111
Anything else?
Found while fixing #63757
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi