[release/7.0] Continue using typeof(void) for empty TypedResults #43990
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is fixing a minor regression from a few hours ago. This only has in impact if you're using the new
TypedResults
with MVC Controllers to populate your ApiExplorer model for things like Swashbuckle.In #43961, I updated the internal
ProducesResponseTypeMetadata
type to accept anull
Type
to match the interface. I thinknull
is still correct for "text/plain" strings returned directly from minimal route handlers. However, I went too far with that change and modified a constructor that our existingTypedResults
were already using to start usingnull
instead oftypeof(void)
even though these are slightly different.aspnetcore/src/Http/Http.Results/src/Ok.cs
Line 53 in 0bb3d68
OpenApiGenerator
andEndpointMetadataApiDescriptionProvider
handletypeof(void)
andnull
the same, so this has no real impact when minimal route handlers returnTypedResults
.aspnetcore/src/OpenApi/src/OpenApiGenerator.cs
Lines 138 to 140 in 0bb3d68
aspnetcore/src/Mvc/Mvc.ApiExplorer/src/EndpointMetadataApiDescriptionProvider.cs
Lines 360 to 363 in 0bb3d68
However, for some reason,
ApiResponseTypeProvider
does treat these differently and excludes all results with anull
type but not avoid
type.aspnetcore/src/Mvc/Mvc.ApiExplorer/src/ApiResponseTypeProvider.cs
Lines 208 to 211 in 0bb3d68
I don't really understand why
ApiResponseTypeProvider
treats these differently while the others don't, but it's been that way for 4 years. I'm more comfortable reverting the unnecessary change I made a couple hours ago. Semantically this makes more sense too.typeof(void)
means there's no response content andnull
means there is content but no schema beyond the Content-Type (e.g. "text/plain").@Pilchie