Repository navigation
Add IEndpointMetadataProvider to UnauthorizedHttpResult - #65611
Merged
Merged
Conversation
Implement `IEndpointMetadataProvider` on `UnauthorizedHttpResult`. Resolves dotnet#65491.
Contributor
|
Thanks for your PR, @@martincostello. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
This was referenced Mar 2, 2026
Open
3 tasks
Youssef1313
marked this pull request as ready for review
July 15, 2026 16:34
Youssef1313
requested review from
a team,
BrennanConroy and
halter73
as code owners
July 15, 2026 16:34
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements IEndpointMetadataProvider on UnauthorizedHttpResult so endpoints that return it (including via Results<...> unions) contribute a 401 response to endpoint metadata, improving OpenAPI document generation. It also updates OpenAPI integration snapshots and adds regression tests to validate metadata extraction.
Changes:
- Implement
IEndpointMetadataProvider.PopulateMetadataonUnauthorizedHttpResultto emitProducesResponseTypeMetadatafor HTTP 401. - Add test coverage in
Http.Resultsand MVC application model tests to validate metadata extraction (includingResults<...>union return types). - Extend the OpenAPI sample and update OpenAPI snapshot baselines to include the new 401 response on the affected endpoint.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Http/Http.Results/src/UnauthorizedHttpResult.cs | Adds IEndpointMetadataProvider implementation to emit 401 response metadata. |
| src/Http/Http.Results/test/UnauthorizedResultTests.cs | Adds unit tests validating PopulateMetadata behavior and null-guarding. |
| src/Mvc/Mvc.Core/test/ApplicationModels/DefaultApplicationModelProviderTest.cs | Adds MVC regression test verifying return-type metadata extraction for Results<...> unions. |
| src/OpenApi/sample/Endpoints/MapSchemasEndpoints.cs | Adds a sample endpoint using a Results<...> union including UnauthorizedHttpResult to drive OpenAPI generation. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentLocalizationTests.VerifyOpenApiDocumentIsInvariant.verified.txt | Updates baseline to include the new 401 response for the added sample endpoint. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_0/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=schemas-by-ref.verified.txt | Updates OpenAPI 3.0 baseline with the new endpoint responses. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_1/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=schemas-by-ref.verified.txt | Updates OpenAPI 3.1 baseline with the new endpoint responses. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_2/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=schemas-by-ref.verified.txt | Updates OpenAPI 3.2 baseline with the new endpoint responses. |
Member
|
@martincostello Could you please address the small comments from Copilot? This will be ready to merge after that 🎉 🚀 |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Youssef1313
approved these changes
Jul 16, 2026
Member
|
Thanks for the contribution @martincostello 🎉 |
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add IEndpointMetadataProvider to UnauthorizedHttpResult
Implement
IEndpointMetadataProvideronUnauthorizedHttpResult.Description
Adds
IEndpointMetadataProvidertoUnauthorizedHttpResultto improve OpenAPI document generation.Will leave in draft until #65491 is approved, but I already had a Copilot generated branch that implemented these changes so figured I'd clean it up and push it now anyway.
Fixes #65491