Skip to content

Inconsistent OpenAPI responses with TypedResults / minimal API #66890

@CaringDev

Description

@CaringDev

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Generated responses (status codes) in OpenAPI documents are inconsistent when returning a result TResult, that result as part of Results<TResults, NotFound> or Results<TResults, NotFound, Ok>.

Expected Behavior

all the following methods should include a 200 response:

FileStreamHttpResult Get(...)
Results<FileStreamHttpResult, NotFound> Get(...)
Results<FileStreamHttpResult, NotFound, Ok> Get(...)

The latter being our current workaround.

Steps To Reproduce

dotnet new webapi
dotnet package add Microsoft.Extensions.ApiDescription.Server

add the following before app.Run()

app.MapGet("/ok200", () => TypedResults.File([]));
app.MapGet("/NOK/", new Func<Results<FileContentHttpResult, NotFound>>(() => TypedResults.File([])));
app.MapGet("/okok/", new Func<Results<FileContentHttpResult, NotFound, Ok>>(() => TypedResults.NotFound()));

Exceptions (if any)

No response

.NET Version

10.0.300

Anything else?

related: #65371

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions