Allow document transformers to access operation descriptions (#61264)#65777
Allow document transformers to access operation descriptions (#61264)#65777vvimjam wants to merge 3 commits intodotnet:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an OperationDescriptions property to OpenApiDocumentTransformerContext, enabling document transformers to access the mapping between OpenApiOperation instances and their ApiDescription metadata. This addresses the scenario where users need to inspect endpoint metadata (e.g., [AllowAnonymous]) during document-level transformations.
Changes:
- Added a new
OperationDescriptionsproperty (IReadOnlyDictionary<OpenApiOperation, ApiDescription>) toOpenApiDocumentTransformerContext. - Plumbed a
Dictionary<OpenApiOperation, ApiDescription>throughGetOpenApiPathsAsyncandGetOperationsAsyncinOpenApiDocumentServiceto populate the mapping. - Added two tests verifying that document transformers can access operation descriptions and endpoint metadata.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/OpenApi/src/Transformers/OpenApiDocumentTransformerContext.cs |
New OperationDescriptions public property |
src/OpenApi/src/Services/OpenApiDocumentService.cs |
Populates and passes the operation-to-description dictionary |
src/OpenApi/test/.../DocumentTransformerTests.cs |
Two new tests for the feature |
|
@dotnet-policy-service agree |
|
Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime. |
Allow document transformers to access operation descriptions
Summary of the changes (Less than 80 chars)
Description
"Added an OperationDescriptions to OpenApiDocumentTransformerContext to allow document transformers to access endpoint metadata."
Fixes #61264
OpenApiDocumentTransformerContext: Added OperationDescriptions property (IReadOnlyDictionary) to provide direct access to the C# metadata (attributes) for each operation.OpenApiDocumentService: Captured the mapping during the generation of paths and operations and passed it to the transformer execution context.PublicAPI.Unshipped.txt: Updated the public API definitions to include the new property.