dotnet / dotnet/aspnetcore

`RequestDelegate`-based handlers do not surface in OpenAPI descriptions

Open
#44,970 13 comments 1 reaction 0 assignees View on GitHub
area-minimal feature-openapi
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

hi I found that the minimal Api TypedResults method does not automatically inject HttpContext.
The httpcontext principle is here in the reference
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-7.0#binding-precedence

### Expected Behavior

The TypedResults method can automatically inject HttpContext.

### Steps To Reproduce

File:Program.cs
```
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.MapGroup("/connect").MapConnect();

app.Run();
```
File:Connect.cs
```
public static class Connect
{
public static RouteGroupBuilder MapConnect(this RouteGroupBuilder group)
{
group.MapGet("/authorize", AuthorizeAsync);
group.MapGet("/GoodMinimalApi", GoodMinimalApi);
return group;
}
public static async Task GoodMinimalApi() // not HttpContext
{
await Task.CompletedTask;
return TypedResults.Ok();
}
public static async Task AuthorizeAsync(HttpContext context)
{
await Task.CompletedTask;
return TypedResults.Ok();
}
}
```
End result

![image](https://user-images.githubusercontent.com/48701698/200835675-7e07e49e-5c9c-45a4-8dce-1172fb7711c0.png)

### Exceptions (if any)

_No response_

### .NET Version

dotnet 7.0

### Anything else?

Microsoft Visual Studio Enterprise 2022 (64 位) - Current版本 17.4.0
ASP.NET Core 7
Minimal Api

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.