Skip to content

fix(common-openapi): resolve full servers[] precedence in OpenapiOperationView#2026

Merged
jfallows merged 2 commits into
developfrom
claude/github-issue-2020-znesqk
Jul 5, 2026
Merged

fix(common-openapi): resolve full servers[] precedence in OpenapiOperationView#2026
jfallows merged 2 commits into
developfrom
claude/github-issue-2020-znesqk

Conversation

@jfallows

@jfallows jfallows commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Description

OpenapiOperationView.servers previously only reflected an operation's own servers[] array, falling straight back to the root/document-level servers[] when absent — it never looked at path-item-level servers[]. This change wires the path-item's servers[] through OpenapiPathView into OpenapiOperationView, so operation.servers now resolves the full OpenAPI precedence: operation-level > path-item-level > root-level.

While implementing this, OpenapiOperationView (and, by extension, the new path-item level) also now mirrors OpenapiView's handling of an empty configs list — previously, an operation or path declaring its own servers[] combined with an empty server-config list would silently resolve to zero servers instead of falling back to using the model's own server URL directly.

The issue also raised the silent-fallback-on-mismatch behavior in OpenapiServerView.VariableMatcher (a caller-supplied server URL override that doesn't match the variable's allowed pattern silently substitutes the declared default). After investigation, this PR intentionally leaves that fallback as-is: binding-mcp-openapi already treats a configured server URL as an unconditional override elsewhere (its resolveServerOverride bypasses common-openapi's matcher entirely), and OpenapiOperationView.servers cross-products every model server against every configured override, so a non-matching pairing is the expected outcome whenever more than one server or config is declared — not a misconfiguration to reject.

This is a building block for downstream work (e.g. binding-openapi-asyncapi) that currently duplicates parts of the servers[] precedence logic; simplifying that downstream duplication is left for a follow-up change.

Testing

Added unit tests in OpenapiViewTest covering:

  • Operation-level servers[] taking precedence over path-item and root
  • Path-item-level servers[] taking precedence over root when the operation declares none
  • Root-level servers[] fallback when neither operation nor path-item declare any
  • Server URL variable resolution using the declared default when no override is supplied
  • Server URL variable resolution using a matching caller-supplied override
  • Server URL variable resolution falling back to the default when a caller-supplied override doesn't match the variable's allowed pattern

./mvnw test -pl runtime/common-openapi passes, along with the existing test suites for binding-openapi, binding-openapi-asyncapi, and binding-mcp-openapi.

Fixes #2020

claude added 2 commits July 5, 2026 19:12
…ationView

Wire path-item-level servers[] through OpenapiPathView into
OpenapiOperationView so operation.servers resolves operation > path-item >
root precedence per the OpenAPI spec, instead of skipping the path-item
level entirely. Also mirror OpenapiView's empty-configs handling so
operation/path-level servers aren't silently dropped when no server
configs are supplied.

Make server URL variable resolution explicit: a templated server URL whose
configured override doesn't match the declared variable pattern now throws
OpenapiException instead of silently falling back to the variable's
default value. Non-templated server URLs are unaffected since there is no
variable to mismatch against.

Closes #2020
…able mismatch

Revert the OpenapiException-on-mismatch behavior added for server URL
variable resolution. binding-mcp-openapi already treats a configured
server URL as an unconditional override elsewhere (resolveServerOverride
bypasses common-openapi's matcher entirely), and OpenapiOperationView.servers
cross-products every model server against every configured override, so a
non-matching pairing is the expected case whenever more than one server or
config is present, not a misconfiguration. Throwing there would break that
case rather than catch a real error.

@jfallows jfallows left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LGTM

@jfallows jfallows merged commit 58fa8b8 into develop Jul 5, 2026
42 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.

common-openapi: resolve full servers[] precedence (operation > path-item > root) in OpenapiOperationView

2 participants