Skip to content

Expose the matched operation on SchemaValidator::OpenAPI3 - #479

Merged
geemus merged 1 commit into
interagent:masterfrom
amogiska:expose-operation-object
Sep 7, 2026
Merged

Expose the matched operation on SchemaValidator::OpenAPI3#479
geemus merged 1 commit into
interagent:masterfrom
amogiska:expose-operation-object

Conversation

@amogiska

@amogiska amogiska commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

The OpenAPI 3 schema validator matches the request to an operation and holds it in @operation_object, but offers no public reader, so applications that want the matched operation have to use instance_variable_get.

One concrete use case: recording HTTP request metrics labeled by the matched original_path template, which keeps the label set bounded by the schema's paths instead of raw request paths (see ubicloud/ubicloud#6271, where a committee maintainer asked us to get a supported API here rather than read the ivar).

This adds a documented attr_reader :operation_object (returns the OperationWrapper, or nil when nothing matched) plus a test.

Applications sometimes need the operation the validator matched, for
example to use its original_path as a low-cardinality metrics label.
The validator already holds it in @operation_object with no public
reader, forcing instance_variable_get. Add a documented attr_reader.
@amogiska
amogiska force-pushed the expose-operation-object branch from 48f52e9 to 32011e8 Compare September 1, 2026 17:25

@geemus geemus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, thanks!

@geemus
geemus merged commit 0d6d111 into interagent:master Sep 7, 2026
9 checks passed
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.

2 participants