Swashbuckle.AspNetCore
Swashbuckle.AspNetCore copied to clipboard
Minimal API endpoints with only Microsoft.AspNetCore.Http parameter does not appear in swagger-output
I use Version 6.2.3.0
I want to use minimal API with swagger, but if i use the "HttpContext" in the parameter-list, the endpoint is not showing in the swagger-result (json and output).
The error only happens if the "HttpContext" parameter stands alone.
Is this a bug or a misunderstanding ?
You can see the example above, the endpoint "WithContext" is not showing in swagger-output/json, all ohter are showing.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
app.UseSwagger();
app.MapGet("/", () => "Hello World!"); // => is showing
// is showing
app.MapGet("/WithHttpResonse", async (HttpResponse response) =>
await response.WriteAsJsonAsync("Test")).WithName("GetWithHttpResonse");
// is showing
app.MapGet("/WithHttpResonseV2", async (HttpResponse response,HttpContext httpContext) =>
await httpContext.Response.WriteAsJsonAsync("Test")).WithName("GetWithHttpResonseV2");
// DOES NOT APPEAR
app.MapGet("/WithContext", async (HttpContext context) =>
await context.Response.WriteAsJsonAsync("Test")).WithName("GetWithContext");
app.MapSwagger();
app.UseSwaggerUI();
app.Run();
Expected Behavior
The endpoint "WithContext" is showing in the swagger-output.
.NET Version and Enviroment
Visual Studio Community 2022 (17.0.5)
Swashbuckle.AspNetCore Version=6.2.3.0
.NET SDK (reflecting any global.json):
Version: 6.0.101
Commit: ef49f6213a
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19043
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.101\
Host (useful for support):
Version: 6.0.1
Commit: 3a25a7f1cc
.NET SDKs installed:
6.0.101 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Anything else?
No response