Repository navigation
feat(common-json,binding-openapi): OpenAPI Overlay Specification support - #2130
Merged
Merged
Conversation
Implements the JSONPath-targeted actions engine from the OpenAPI Overlay Specification (1.0.0), scoped to the small JSONPath (RFC 9535) subset the spec actually needs (root, dot/bracket member access, integer indices, wildcards) rather than pulling in a non-modular JSONPath dependency. JsonPath compiles an expression and matches it against a JsonValue tree, yielding RFC 6901 pointers. JsonOverlay applies a sequence of update/remove actions in order, re-evaluating each target against the document as edited by prior actions, using the existing JsonPatch/JsonPointer support in this module's JsonProvider. Ref: #2127
Wires JsonOverlay (from common-json) into the existing catalog-resolve seam in OpenapiCompositeGenerator.generate(): an optional new options.specs.<label>.overlay reference, shaped like the existing catalog reference, is resolved via the same CatalogHandler and its actions are applied to the resolved spec payload before OpenapiParser parses it. This lets an operator patch a spec they can't edit directly (e.g. one fetched from a schema registry) without touching the source document. Establishes the reference integration pattern for the sibling composite generators (binding-asyncapi, binding-openapi-asyncapi, binding-mcp-openapi) to follow in a later change. Ref: #2127
jfallows
pushed a commit
that referenced
this pull request
Jul 11, 2026
… spec is parsed Extends the OpenAPI Overlay integration pattern from #2130 to asyncapi: an optional options.specs.<label>.overlay reference, shaped like the existing catalog reference, is resolved via the same CatalogHandler and its JsonOverlay actions are applied to the resolved spec payload before AsyncapiParser parses it. Mirrors OpenapiCompositeGenerator.materialize() and OpenapiSpecificationConfig/OpenapiOptionsConfigAdapter exactly. Ref: #2127
12 tasks done
jfallows
added a commit
that referenced
this pull request
Jul 12, 2026
…-mcp-openapi): close options.* abstraction leaks and align spec/apiId terminology (#2128) * fix(binding-asyncapi,binding-openapi-asyncapi,binding-openapi): resolve {identity} against the actual guard, not a hardcoded :jwt0 resolveIdentity() previously always rewrote {identity} to ${guarded['<namespace>:jwt0'].identity} regardless of which guard `security` actually resolved for the operation. Thread the resolved GuardedRef.qname through to each resolveIdentity call site instead; when no guard resolves, leave {identity} unresolved rather than referencing a guard that likely doesn't exist. Consolidates the ad-hoc AsyncapiGuardResolver.resolve(...) calls in AsyncapiProxyGenerator into the shared resolveGuarded()/guardQname() helpers already used for allowed(). Fixes #2113 (item 4). * fix(binding-asyncapi): move mqtt.store to specs.<name>.store MQTT session/retained-message store selection was a global options.mqtt.store, the only per-transport field in a binding whose protocol mapping is otherwise entirely per-spec (security, catalogs, servers). Move it under options.specs.<name>.store, consistent with that pattern; ignored where the spec's protocol doesn't use it. AsyncapiServerGenerator now reads the resolved store from the per-schema AsyncapiSchemaConfig instead of the binding-wide AsyncapiOptionsConfig.mqtt.store, falling back to the default in-memory mqtt_store0 store when unset, same as before. Fixes #2113 (item 2). * fix(binding-asyncapi): wire options.kafka.authorization into the generated Kafka client KafkaOptionsConfig already mirrors HttpOptionsConfig/MqttOptionsConfig with both a legacy sasl field and an authorization field resolvable to a guard qname, but AsyncapiClientGenerator only ever read options.kafka.sasl -- options.kafka.authorization was parsed and schema-validated for every other transport but silently ignored for Kafka, and had no schema entry at all on the asyncapi binding. Resolve options.kafka.authorization.qname in AsyncapiBindingConfig the same way http/mqtt authorization already are, and inject it into the generated kafka_client0 binding's options alongside sasl. Partial fix for #2113 (item 1a); guard multiplicity / per-server-group guard divergence (item 1b) is tracked separately as it is a larger design change, not a field wiring fix. * fix(binding-openapi,binding-asyncapi): populate TLS authority for SNI routing TlsConditionConfig already supports authority-based (SNI) routing -- used elsewhere in the codebase -- but OpenapiServerGenerator and AsyncapiServerGenerator's injectTlsRoutes never populated it, only port. Wire each declared server's hostname into the generated TLS route condition so SNI-based dispatch works when multiple TLS servers share a port. This is the bounded, unambiguous part of #2113 (item 1b) -- wiring up an existing TlsConditionConfig capability. The broader "generate one http_server0-equivalent per distinct-guard server-group" change is left out of this PR: the issue itself flags the guard-group derivation and dispatch design as an open question the author hadn't resolved, and guessing at that shape risks building something that has to be reworked once it's actually settled. * feat(binding-asyncapi): replace options.mqttKafka.channels with x-zilla-mqtt-kafka extension Channel-to-role mapping (sessions/messages/retained) for the MQTT-Kafka proxy now lives on the Kafka spec itself, as an x-zilla-mqtt-kafka extension on each channel, instead of a separate options.mqttKafka.channels block that duplicated channel names the operator could get out of sync with the spec. Resolves the mqttKafka.channels portion of #2113. * fix(binding-asyncapi): open extensions.mqtt.kafka package for JSON-B reflection AsyncapiMqttKafkaChannelEx.role deserializes via reflective field access, but the package wasn't opened in module-info.java. Unit tests run on the classpath (no module boundary) so this passed locally, but the real modular runtime image throws IllegalAccessException on startup, failing config load for any spec using x-zilla-mqtt-kafka -- surfaced by the asyncapi.mqtt.kafka.proxy example's CI healthcheck failure on PR #2128. Confirmed by launching the engine directly on the module path against the example config: reproduced the ConfigException before the fix, and verified TCP port 7183 opens successfully after it. * feat(binding-asyncapi,common-asyncapi): apply AsyncAPI Overlay before spec is parsed Extends the OpenAPI Overlay integration pattern from #2130 to asyncapi: an optional options.specs.<label>.overlay reference, shaped like the existing catalog reference, is resolved via the same CatalogHandler and its JsonOverlay actions are applied to the resolved spec payload before AsyncapiParser parses it. Mirrors OpenapiCompositeGenerator.materialize() and OpenapiSpecificationConfig/OpenapiOptionsConfigAdapter exactly. Ref: #2127 * fix(binding-asyncapi): wire kafka topic defaultOffset/deltaType, clear mqtt-kafka role error options.kafka.topics[].defaultOffset and deltaType were accepted by the schema (reused from binding-kafka's own topic schema) but never applied to the generated kafka_cache_client0/kafka_cache_server0 topic options -- an operator asking for defaultOffset: historical silently got live instead. Also guards against the missing-transforms case this exposed: injectKafkaTopicConfig now only builds a transforms block when the operator actually configured one, instead of NPEing on any topic entry that sets defaultOffset/deltaType without transforms. Separately, injectMqttKafkaOptions NPEd with no context when a Kafka spec's x-zilla-mqtt-kafka extension was missing one of the three required roles (sessions/messages/retained). requireMqttKafkaRole now reports which role is missing. Found via an options.* abstraction-leak audit of the composite-generator bindings, following up on #2113. * feat(binding-openapi-asyncapi): apply Overlay to both openapi and asyncapi specs, thread asyncapi security to schema config Extends the Overlay materialize() pattern (already present in binding-openapi and binding-asyncapi) to binding-openapi-asyncapi's composite generator, for both the openapi and asyncapi legs. Previously options.specs.*.overlay was not exposed in this binding's schema/adapter at all, so operator-supplied overlays were silently unreachable. Also threads asyncapiSpec.security into AsyncapiSchemaConfig construction, matching the parity already present on the openapi side and in binding-asyncapi's own composite generator. Consuming that value for Kafka-side guard resolution is tracked separately in #2133, since it requires a design decision (Zilla routes support only one guard per route). Ref: #2113 * feat(binding-mcp-openapi): add options.authorization for outbound credential forwarding Adds options.authorization (name + credentials.headers, matching the same convention used by binding-mcp and binding-mcp-http) so mcp-openapi can declare a guard whose resolved credentials/identity get forwarded into the generated mcp_http binding's outbound headers via {credentials}/{identity} substitution -- a mechanism McpHttpBindingConfig.resolveCredentials() already supports but mcp-openapi's composite generator never exposed, always passing null. The guard name is resolved to its qualified name in McpOpenapiBindingConfig's constructor, mirroring AsyncapiBindingConfig's existing authorization.qname resolution pattern, so the composite generator can wire it straight into the generated binding without re-resolving. Ref: #2113 * feat(binding-mcp-openapi): add overlay support for openapi specs Extends the Overlay materialize() pattern (already present in binding-openapi, binding-asyncapi, and binding-openapi-asyncapi) to binding-mcp-openapi's composite generator. Previously options.specs.<name>.overlay was blocked by additionalProperties: false in the schema and had no adapter or generator support, so an operator-supplied overlay was unreachable. Ref: #2113 * fix(binding-openapi): guard against null server url in adaptToJson OpenapiOptionsConfigAdapter.adaptToJson threw an NPE when a spec's server had no url configured, even though the schema allows it and adaptFromJson already null-checks the same field on the read path. * fix(binding-mcp-openapi): derive resource template flag from the generated uri McpOpenapiCompositeGenerator computed the template flag from operation.path, but resourceUri() can append an RFC 6570 query-capture suffix ({?param}) even when the path itself has no {pathParam} segments. This misclassified query-only resources as static/concrete, producing a uri containing an unexpanded {...} expression on a resource advertised via resources/list, which violates the MCP contract (a static resource's uri must be concrete). Fixed the existing test's assertion, which had been asserting the wrong behavior. * fix(binding-asyncapi): make options.specs.<name>.server override consistently govern protocol security and Kafka broker address Two related bugs in AsyncapiClientGenerator when a spec's server: override disagrees with the AsyncAPI spec's own declared server protocol: - injectProtocols() selected the http/mqtt/kafka injector variant (and therefore the generated binding's exit target) purely from the spec's declared protocol, never consulting the override's security class. This produced a dangling exit to a tls_client0 binding that injectTlsClient() never created (override plain, spec secure), or a silent plaintext downgrade with an unused tls_client0 left dangling (override secure, spec plain). This exact mismatch already existed undetected in the checked-in client.kafka.yaml fixture, invisible only because its IT drives the internal kafka0 stream directly, bypassing the network/TLS exit chain. - injectKafkaServerOptions() built the Kafka client's broker host/port solely from the spec's declared servers, never from the override -- unlike injectHttpOptions/injectMqttOptions, which both already apply it. Added resolveProtocol() to normalize a declared protocol to its plain/secure variant based on the override when present, and threaded resolveServer() into injectKafkaServerOptions to mirror the existing HTTP/MQTT pattern. * fix(binding-openapi-asyncapi): make options.specs.*.server/servers reachable OpenapiAsyncapiOptionsConfigAdapter hardcoded server=null and servers=List.of() when parsing openapi specs, and never parsed server/servers at all for asyncapi specs, so the override was silently dropped no matter what the operator configured. servers (the list) already feeds OpenapiView/AsyncapiView server variable substitution downstream in OpenapiAsyncapiCompositeGenerator, so these values were previously unreachable regardless of user config. Wire both read and write paths for openapi.server/servers and asyncapi.server/servers, mirroring the existing OpenapiOptionsConfigAdapter and AsyncapiOptionsConfigAdapter patterns, and add the matching schema patch properties. * fix(binding-openapi-asyncapi): consume x-zilla-http-kafka key/overrides OpenapiHttpKafkaOperationEx.key and .overrides were parsed from the x-zilla-http-kafka vendor extension but never read anywhere -- only .filters was consumed. Mirror the sibling binding-asyncapi AsyncapiProxyGenerator's already-working produce-path handling: key overrides the Kafka message key (taking precedence over the auto-derived path-param/idempotencyKey default), and each overrides entry becomes a produce header override, with {identity} substitution via resolveIdentity(). * fix(binding-mcp-openapi): add mimeType override for resources Resources had no way to override the MCP mimeType derived from the OpenAPI operation's success response content type, unlike description/output which already supported an operator override. Add mimeType to McpOpenapiResourceConfig and its builder/adapter/schema, and prefer it over the OpenAPI-derived value in injectMimeType(). Also fixes injectResourceOverrides() silently dropping mimeType (and would have dropped any future override field the same way, since it copied fields one by one instead of the whole config). * fix(binding-mcp-openapi): pick a deterministic content type for resource mimeType injectMimeType() picked "the first" entry from OpenapiResponseView.content, a map built via a bare Collectors.toMap that defaults to HashMap -- so with more than one declared response content type, the chosen mimeType depended on hash bucket order, not spec declaration order. Preserve declaration order in OpenapiResponseView.content and prefer a JSON content type when present (mirroring the existing jsonContentType pattern in OpenapiAsyncapiProxyGenerator), falling back to the first declared entry. * feat(common-openapi,common-asyncapi): add literal server url fields alongside override-resolved ones OpenapiServerView/AsyncapiServerView now expose literalUrl (and literalHost/literalPathname for asyncapi) computed via the same VariableMatcher against config=null always, plus an `overridden` flag on OpenapiServerView recording whether a config override actually matched this declared server's own pattern. These give downstream when.servers matching a portable, deployment-independent value to compare against, decoupled from whatever options.specs.*.server override happens to be configured. * fix(binding-openapi): collapse options.specs.*.servers to singular server, fix when.servers vanilla matching options.specs.*.servers (plural override list) is redundant with the spec document's own declared servers times a single deployment override; no config anywhere ever configured more than one entry. Collapse to the existing singular server override field. when.servers.url now matches against the spec's own literal declared value instead of the override-resolved effective value, so editing an unrelated options.specs.*.server deployment override no longer silently changes what a when.servers.url route condition matches. Also fixes a double path-prefix bug this collapse would otherwise surface: options.server composes a path prefix on top of each doc-declared server only when the override does not itself match one of those declared servers (the common reverse-proxy-in-front case); when it does match (pinning a specific declared server, as in server.env.prod.yaml), the matched server's own resolved url already carries the correct path and the prefix must not be added again. * fix(binding-asyncapi): collapse options.specs.*.servers to singular server, fix when.servers vanilla matching Same collapse and vanilla-matching fix as binding-openapi: options.specs.*.servers (plural) is dropped in favor of the existing singular server override; when.servers.url now compares against AsyncapiServerView.literalUrl instead of the override-resolved url. Adds when.servers-driven route selection coverage for the asyncapi proxy (mqtt-kafka mapping), previously an untested code path, plus a case in AsyncapiConditionConfigAdapterTest pairing a server override with a when.servers.url condition written against the spec's own literal value to prove the override no longer desyncs the match. * fix(binding-openapi-asyncapi): revert options.specs.*.server(s), add when.servers/when.tag route filtering Reverts the recent options.specs.*.server/servers addition (proxy-kind bindings hold no real connection, so a server override never belonged here) and replaces it with when.servers/when.tag route conditions, consistent with when.spec/when.operation and with the same conditions now available on binding-openapi and binding-asyncapi. OpenapiAsyncapiConditionConfig gains tag/servers fields and a new matches(spec, operation, tags, servers) overload; the exact-match and bulk/glob branches of OpenapiAsyncapiProxyGenerator.injectHttpKafkaRoutes now call it before generating an http-kafka route, mirroring AsyncapiProxyGenerator's existing ProxyOperationHelper.matches gate. Filtering runs against the OpenAPI (HTTP) side's own declared tags/servers, matching how when.spec/when.operation already resolve. * fix(binding-mcp-openapi.spec): fix stale "API Id" title on the spec property The spec property's JSON-Schema title was never updated when the property itself was renamed from apiId to spec. * refactor(common-openapi): rename apiId/apiLabel to specIndex/specLabel apiLabel was the stale pre-rename name for the spec's own config label (OpenapiSchemaConfig.specLabel, matching OpenapiSpecificationConfig.label). apiId in OpenapiCompositeId's bit-packing was a separate, purely composite-local sequential index (never sent over the wire, unrelated to the schemaId-based identifier of the same old name elsewhere in the runtime) - renamed to specIndex to match the sibling serverIndex constant already in this same file, rather than reusing specId, the name given to the wire-carried concept in a following change. * refactor(binding-openapi.spec,binding-openapi): rename wire-level apiId to specId OpenapiBeginEx.apiId was the stale pre-rename name for the resolved spec's catalog schemaId, carried over the wire between the openapi server/client stream factories. Renames the .idl field, the generated flyweight's derived builder/matcher (via OpenapiFunctions), every .rpt fixture referencing it, and every runtime call site (composite condition/route/with configs, OpenapiCompositeConfig.resolveApiId split into resolveSpecId/resolveSpecLabel, and the stream factory fields/locals that read/write the wire field). * refactor(binding-asyncapi.spec,binding-asyncapi): rename wire-level apiId to specId Mirrors the binding-openapi rename: the wire-level AsyncapiBeginEx.apiId field, XxxFunctions builder/matcher, all .rpt fixtures, and the runtime composite condition/route/with configs, composite generators, and stream factories now consistently use spec/specId/specLabel terminology instead of the stale apiId/apiLabel naming. The composite-local sequential index in AsyncapiCompositeId is renamed to specIndex to distinguish it from the wire-carried catalog schemaId (specId). * refactor(binding-openapi-asyncapi.spec,binding-openapi-asyncapi): rename apiId/apiLabel to spec vocabulary Mirrors the binding-openapi and binding-asyncapi renames: rpt fixtures, condition/route/with configs, the composite generator, and the proxy stream factory now consistently use spec/specId/specLabel instead of the stale apiId/apiLabel naming. Also renames the dead-code OpenapiAsyncapiCompositeId.apiId to specIndex for consistency with the sibling common-openapi/common-asyncapi CompositeId helpers, and fixes OpenapiAsyncapiConditionConfig.matchesSpec's param name, which previously contradicted its own method name. --------- Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements the JSONPath-targeted actions engine from the OpenAPI Overlay Specification (1.0.0) and wires it into
binding-openapias the reference integration.common-json(new, generic, protocol-agnostic):JsonPath— a JSONPath (RFC 9535) subset scoped to exactly what Overlay targets need: root ($), dot/bracket member access (including quoted keys for reserved characters), integer array indices (including negative, counted from the end), and wildcards (.*/[*]). No JSONPath library dependency is added — the runtime module system forbids non-modular dependencies anywhere inruntime/, and most JSONPath libraries ship as automatic modules, so the small subset is hand-rolled instead, consistent with how this module already hand-rolls its ownJsonProvider/JSON-Schema engine rather than depending on external libraries.JsonOverlay/JsonOverlayAction— applies a sequence of Overlay actions to aJsonValuedocument.updaterecursively merges into a matched object, appends to a matched array, or replaces a matched scalar;removedeletes matched nodes (highest array index first, so one wildcard-matched removal doesn't corrupt later indices). Each action'stargetis re-evaluated against the document as edited by prior actions. Built on this module's existingJsonPatch/JsonPointersupport — no new machinery needed there.JsonPathTest,JsonOverlayTest).binding-openapi(reference wiring):options.specs.<label>.overlayconfig, shaped identically to the existingspecs.<label>.catalogreference ({ <catalogName>: { subject, version } }) and resolved through the sameCatalogHandler.OpenapiCompositeGeneratorat the seam described in the issue — between resolving the raw spec payload andparser.parse()— viaYamlJson(to handle YAML or JSON spec text) andJsonOverlay.common-openapi's sharedOpenapiSpecificationConfiggets a new (additive, backward-compatible)overlayfield; existing callers inbinding-openapi-asyncapiare unaffected.OpenapiOptionsConfigAdapterTest(read/write round-trip) andOpenapiServerGeneratorTest.shouldApplyOverlayBeforeGeneratingRoutes(proves an overlay-added path reaches the generated composite).Scoped out of this PR: wiring the same
overlayfield intobinding-asyncapi,binding-openapi-asyncapi, andbinding-mcp-openapi. The mechanism and config shape are established here; extending to the other three bindings is mechanical repetition of this pattern, called out as follow-up so an unreviewed config-surface decision doesn't spread across four public schemas in one shot.Fixes #2127
Test plan
./mvnw test -pl runtime/common-json— 33 new tests pass, no regressions (4916 total)./mvnw test -pl runtime/binding-openapi— new adapter + generator tests pass, no regressions (20 total)./mvnw test -pl runtime/common-openapi,runtime/binding-openapi-asyncapi,runtime/binding-mcp-openapi— unaffected, no regressions./mvnw checkstyle:checkclean on all touched modules./mvnw clean install -pl runtime/binding-openapi— confirmsmodule-info.javachange produces a valid modular jar