Skip to content

feat(document): add GetOperationById to search operations across path… - #3025

Open
Mahdigln wants to merge 1 commit into
microsoft:mainfrom
Mahdigln:feature/get-operation-by-id
Open

feat(document): add GetOperationById to search operations across path…#3025
Mahdigln wants to merge 1 commit into
microsoft:mainfrom
Mahdigln:feature/get-operation-by-id

Conversation

@Mahdigln

Copy link
Copy Markdown
Contributor

Description

Adds a GetOperationById(string operationId) method to OpenApiDocument that searches for an operation by its operationId across both Paths and Webhooks.

Closes #1654

Type of Change

  • New feature (non-breaking change which adds functionality)

Related Issue(s)

Closes #1654

Changes Made

  • Added GetOperationById(string operationId) method to OpenApiDocument
  • Method searches both Paths and Webhooks to cover the full document
  • Resolves operations through OpenApiPathItemReference (when the reference is resolved)
  • Added GetOperationById entry to PublicAPI.Unshipped.txt

Testing

  • Unit tests added/updated
  • All existing tests pass

Tests cover:

  • Returns matching operation from Paths
  • Returns matching operation from Webhooks
  • Returns null when not found
  • Case-sensitive matching (getUserGetUser)
  • Resolves operation through a $ref path item
  • Returns first match when duplicate operationId exists (spec violation)
  • Skips unresolved path item references gracefully
  • Throws ArgumentNullException for null or empty operationId

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Versions applicability

  • I have evaluated the applicability of my change against the other versions above.

Additional Notes

GetOperationByRef (resolving operationRef via JSON Pointer) is not included in this PR and can be addressed in a follow-up.

@Mahdigln
Mahdigln requested a review from a team as a code owner August 15, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get operation by ID or ref

1 participant