-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
domaindrivendev/Swashbuckle.AspNetCore
#2231Labels
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 withoutarea-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
Description
Describe the bug
If a Minimal API endpoint uses a route constraint, for example "/status/{code:range(200, 599)}", the constraint is exposed to OpenAPI documentation incorrectly, which causes the API to be called incorrectly, resulting in an HTTP 404.
https://localhost:7168/status/%7Bcode:range(200,%20599)%7D
To Reproduce
Create an empty ASP.NET Core 6 project with a reference to Swashbuckle.AspNetCore with the below code as Program.cs.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new() { Title = builder.Environment.ApplicationName, Version = "v1" });
});
var app = builder.Build();
app.MapGet("/status/{code:range(200, 599)}", (int code) => Results.StatusCode(code));
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.EnableTryItOutByDefault();
options.SwaggerEndpoint("/swagger/v1/swagger.json", $"{builder.Environment.ApplicationName} v1");
});
app.Run();Further technical details
.NET SDK version 6.0.100-rc.1.21460.8
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 withoutarea-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
