Skip to content

Allow document transformers to access operation descriptions (#61264)#65777

Open
vvimjam wants to merge 3 commits intodotnet:mainfrom
vvimjam:bugFix61264/OpenApiOperationDataAccess
Open

Allow document transformers to access operation descriptions (#61264)#65777
vvimjam wants to merge 3 commits intodotnet:mainfrom
vvimjam:bugFix61264/OpenApiOperationDataAccess

Conversation

@vvimjam
Copy link
Copy Markdown

@vvimjam vvimjam commented Mar 13, 2026

Allow document transformers to access operation descriptions

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

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.

@vvimjam vvimjam requested a review from a team as a code owner March 13, 2026 21:11
Copilot AI review requested due to automatic review settings March 13, 2026 21:11
@github-actions github-actions Bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Mar 13, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Mar 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 OperationDescriptions property (IReadOnlyDictionary<OpenApiOperation, ApiDescription>) to OpenApiDocumentTransformerContext.
  • Plumbed a Dictionary<OpenApiOperation, ApiDescription> through GetOpenApiPathsAsync and GetOperationsAsync in OpenApiDocumentService to 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

Comment thread src/OpenApi/src/Transformers/OpenApiDocumentTransformerContext.cs
Comment thread src/OpenApi/src/Transformers/OpenApiDocumentTransformerContext.cs Outdated
Comment thread src/OpenApi/src/Services/OpenApiDocumentService.cs Outdated
@martincostello martincostello added feature-openapi area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Mar 13, 2026
@vvimjam
Copy link
Copy Markdown
Author

vvimjam commented Mar 14, 2026

@dotnet-policy-service agree

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.

@dotnet-policy-service dotnet-policy-service Bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Mar 24, 2026
This was referenced Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc community-contribution Indicates that the PR has been added by a community member feature-openapi pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[OpenAPI] Cannot skip SecurityScheme for controllers with [AllowAnonymous]

4 participants