Skip to content

Conversation

@captainsafia
Copy link
Member

Closes #56975.

I introduced in a regression in 8da6daa that meant that IResult types (which don't expose any metadata) were erroneously inserted into ApiResponseTypes. This regression wasn't caught because the test cases that existed optimized for void-returning awaitables and didn't factor in result types that implemented IEndpointMetadataProvider.

To resolve this issue, I've made some changes to treat IResult-types directly in the response and those included in metadata as void responses that should not map to ApiResponseTypes. I also included additional tests for handling of typed results in ApiExplorer.

@ghost ghost added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jul 29, 2024

foreach (var metadata in responseMetadata)
{
// `IResult` metadata inserted for awaitable types should
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't tell from this comment whether IResult only appears because we inserted it. Is there a case where it's present legitimately and we shouldn't skip it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's theoritically feasible that IResult could appear there if someone manually insert it by doing something like:

app.MapGet()
	.Produces<IResult>("application/json");

In either case, it still stands that IResult doesn't provide us with type information specific enough to include in the response type information.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like "IResult (usually inserted for awaitable types) isn't useful..."?

@captainsafia captainsafia merged commit 6dc454f into main Jul 31, 2024
@captainsafia captainsafia deleted the iresult-followup branch July 31, 2024 02:26
@dotnet-policy-service dotnet-policy-service bot added this to the 9.0-rc1 milestone Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[9.0-preview7] Response schema being returned as IResult

3 participants