Repository navigation
fix(common-asyncapi): parse channel-level servers scoping and missing server fields - #2151
Merged
Merged
Conversation
…g server fields AsyncapiChannel.servers ($ref list into the document's top-level servers map) was previously undeclared and silently dropped during deserialization, so every channel/operation was treated as available on every server regardless of AsyncAPI 3.0's channel-level servers restriction. Add the field, a AsyncapiServerResolver to resolve #/servers/... refs, and thread a resolved AsyncapiServerView list through AsyncapiChannelView and AsyncapiOperationView (falling back to every declared server when the channel's servers list is absent or empty, per the spec). Also add protocolVersion/title/summary/description/tags to AsyncapiServer, which the schema already allows and existing spec fixtures already set, but were previously discarded for lack of a model field. Wiring this into binding-asyncapi's when.servers[] route condition is left for a follow-up, since that mechanism today is a coarse per-spec filter and needs its own design pass to become genuinely per-operation. Fixes #2150.
jfallows
pushed a commit
that referenced
this pull request
Jul 13, 2026
… routing Swap the three call sites that fed the coarse, spec-wide server list into AsyncapiConditionConfig/AsyncapiBindingConfig.resolve for the real, per-operation-scoped list added by #2151: AsyncapiProxyGenerator's generation-time route matching, and AsyncapiServerFactory/AsyncapiProxyFactory's runtime route dispatch. A channel scoped to a subset of a spec's servers now correctly excludes routes whose when.servers[] condition targets a different server. Realign the composite/asyncapi mqtt and kafka k3po fixtures' hardcoded compositeId literals with AsyncapiCompositeId's simplified 2-field (specIndex, operationId) encoding now that the vestigial server-index dimension is gone. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k
jfallows
added a commit
that referenced
this pull request
Jul 14, 2026
…tory boundary (#2152) * fix(binding-openapi,common-openapi): canonicalize openapi request shape at server/client boundary Follow-up to #2113/#2128: implements #2145's canonicalize/un-canonicalize proposal so openapi-asyncapi and downstream bindings operate purely on canonical specId/operationId terms, never on options.specs.*.server. Foundational fixes required first (found while implementing): - options.specs.<label>.server now wholesale-replaces a single declared server's URL instead of falling back to the literal default and double-prefixing the override's path on top of it (server.route.prefix.yaml was asserting the resulting double-prefixed /apis/v1/pets as correct). Multi-server exact-match disambiguation (for when.servers routing) is preserved unchanged. - TCP/TLS listen-address selection (ports/injectTcpRoutes/injectTlsRoutes) now reads literalUrl instead of url, since url can now diverge in scheme/host from the spec's own declared listen address once an override is wholesale-applied. - Zero declared servers (at any level) now synthesize the OpenAPI-spec's own implicit {url: "/"} default instead of leaving servers null, fixing a pre-existing silent-unreachable-route/latent-NPE gap and removing a case the canonicalization logic would otherwise need to special-case. Canonicalization itself: - OpenapiServerFactory now rewrites the HttpBeginEx it forwards downstream: drops :scheme/:authority and rewrites :path down to the operation's own canonical (unprefixed) shape, via a new OpenapiBindingConfig.resolve(...) entry point. - OpenapiClientFactory reconstructs the effective, deployment-specific shape (re-injecting :scheme/:authority, re-prefixing :path) via the symmetric OpenapiBindingConfig.resolve(...) overload before handing off to the generated http_client0 binding. - OpenapiServerView gains effectivePrefixLength()/canonicalPrefixLength(), pure functions of url/literalUrl, used by both rewrite directions. - binding-openapi-asyncapi needs no code change: it already always parses with an empty OpenapiServerConfig, so its generated http_kafka_proxy0 when.path conditions were already canonical-shaped; they become correct now that the upstream bytes are too. Verified: full ./mvnw verify green on runtime/binding-openapi, runtime/common-openapi, specs/binding-openapi.spec, and runtime/binding-openapi-asyncapi (unchanged, confirming no regression). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * refactor(common-openapi,binding-openapi): keep OpenapiServerView pure, derive canonical path from operation OpenapiServerView (and OpenapiView/OpenapiOperationView) no longer take an options.specs.*.server override at construction time - they stay a faithful, config-free view of the parsed spec. Generators combine that pure view with the binding's own options.specs.*.server via OpenapiBindingConfig.resolveEffectiveUrl, instead of baking the override into the view itself. This also simplifies the runtime (un)canonicalize transform at the server/client boundary: canonicalizing no longer needs any prefix-length arithmetic or config lookup at all - it just rebuilds :path from the already resolved operation's own path against the canonical server. Un-canonicalizing on the client side resolves the effective base (override or canonical) once per BEGIN and reconstructs :scheme/:authority/:path from it. Fixes the canonical path shape itself: it must retain the spec's own declared server prefix (e.g. /v1/pets) rather than the bare operation path, which is what the openapi-asyncapi proxy's independently generated Kafka route already expects. Adds a red/green composite test (shouldCreatePetWithServerPathPrefix) proving a server path-prefix override combined with Kafka-proxying now routes correctly. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * refactor(binding-openapi): collapse resolveServerOverride+resolveEffectiveUrl into resolveServer The two static helpers were always called back-to-back at every call site (look up the override, then combine it with the canonical view), so fold them into one instance method on OpenapiBindingConfig - the natural owner, since it already holds the options this combination depends on. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * refactor(binding-openapi,common-openapi): options.specs.*.server drives TCP/TLS/HTTP uniformly, make it required options.specs.*.server is meant to make the API's base URL wholesale relocatable (per OpenAPI's own servers: semantics) - so it must drive TCP/TLS listen address and HTTP path generation together, not just HTTP path while TCP/TLS stay pinned to the spec's own declared server. Collapses resolveServerOverride+resolveEffectiveUrl into a single resolveBaseURL(specLabel) returning the resolved override URI directly (no server/singular argument needed - override, when present, always wins wholesale, uniformly across every declared server for that spec label, since there's exactly one physical deployment target). Since an override now determines physical bind behavior, options.specs.*.server becomes a required field in the openapi binding's JSON schema (previously optional) - omitting it left "does this spec have a real deployment address" ambiguous. Existing fixtures whose override previously differed from the physical listen address (e.g. https://frontend.example.com) are updated to a value consistent with where they actually listen, to avoid needing to fabricate TLS material just for the override's scheme to be real. Fixture updates for the remaining configs that omitted options.specs.*.server entirely are in progress as a follow-up commit. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * test(binding-openapi.spec): add required options.specs.*.server to config fixtures Follow-up to 702dc0a, which made options.specs.*.server required in the openapi binding's JSON schema. These fixtures previously omitted it entirely; each now declares a server matching its own embedded spec's canonical servers: url, so behavior is unchanged. Remaining binding-openapi-asyncapi.spec fixtures still need the same fix. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * fix(binding-openapi.spec): fix stray closing brace in OpenapiClientGenerator, add missing server: fixture OpenapiClientGenerator.injectHttpRequests had a leftover extra closing block from an earlier edit (dropped the now-unneeded singular local but left its enclosing braces behind). server.secure.yaml was missed by the earlier required-server fixture pass because it also declares a `server:` vault, which threw off the file-level grep check. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * refactor(binding-openapi): drop the no-override fallback now that server is required resolveBaseURL never returns a missing override for a schema-valid config, so the generators and OpenapiBindingConfig.resolve() no longer need to fall back to each canonical server's own url. TCP/TLS/HTTP server generation and the client's scheme/authority/path resolution now use a single resolved base URL directly. Per-operation HTTP request/response validation entries collapse to one per operation instead of one per declared canonical server, since they'd otherwise be exact duplicates - only the per-server compositeId route disambiguation in injectHttpRoutes still iterates every declared server, since that's what lets OpenapiServerFactory resolve which canonical server matched for routes[].when.servers filtering. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * refactor(binding-asyncapi): make options.specs.*.server required, drop no-override fallback Mirrors the binding-openapi fix: options.specs.*.server is now schema-required for server/client/proxy kinds, since a spec's declared server is meant to be wholesale relocatable, not merged with a deployment-specific override. Drops the now-dead null-server fallback branches in AsyncapiClientGenerator and AsyncapiCompositeGenerator. Known consequence, accepted: a multi-broker Kafka bootstrap list in a spec's servers: collapses to the single configured override broker, since the override is one address, not a list. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * feat(binding-openapi): options.specs.*.server(s) becomes a plural, relocatable base-URL list Replace the singular required options.specs.<name>.server string with a servers array (minItems 1). A spec's declared servers can now be relocated to several equivalent deployment base URLs at once, not just one. Server kind fans out TCP/TLS/HTTP route and request-template generation across every configured server URI within the same tcp_server0/tls_server0/ http_server0 trio, instead of one physical listener per override. Client kind keeps a single http_client0/tls_client0 pair; OpenapiClientFactory now round-robins across the configured servers per (binding, spec) so every entry is a real, reachable target, and drops the static ":authority" options override that would have clobbered per-stream dynamic target selection. Also removes routes[].when[].servers: tracing OpenapiServerFactory showed it already matched against the canonical per-declared-server url while every generated route for an operation carried an identical :path condition once the override became uniform, so the filter had already gone silently inert. repurpose server.route.servers.yaml as a multiple-servers regression fixture now that its former when.servers-based route disambiguation is gone. * test(binding-openapi): replace client round-robin unit test with a k3po IT Drop OpenapiClientFactoryTest (this binding proves stream-factory behavior through k3po ITs, not Mockito unit tests, matching every other test class in this module). Add OpenapiClientIT#shouldRoundRobinAcrossServers instead: a two-server client config with real accept sockets on two different ports, proving consecutive requests actually land on both configured targets in order, not just that the in-memory selector alternates. * fix(binding-openapi): restore when.servers as generation-time filter, drop compositeId server-index The options.specs.*.servers[] rollout introduced arbitrary compositeId resolution whenever an operation declares more than one canonical server: injectHttpRoutes looped the canonical-server axis outer and the deployment override axis inner, so every canonical variant produced an identical :path condition and first-match-wins made compositeId's server-index arbitrary. Since compositeId drove canonicalize's server lookup, a request could be canonicalized against the wrong declared server. Separate the two axes that were conflated: deployment relocation (options.specs.*.servers[], a pure runtime concern, unchanged) from canonical declared-server scoping (a pure generation-time concern). Restore when.servers as a generation-time inclusion filter only (not a runtime route disambiguator) — it now decides which operations a route's config includes, based on the operation's own declared servers. Once inclusion is decided once at generation time, compositeId no longer needs a server-index component at all: canonicalize only needs the bare operation path, and un-canonicalize only needs the resolved deployment URI plus the path already on the wire. This eliminates the bug structurally. Also fixes canonicalize/un-canonicalize to use the operation's bare path as the canonical form, rather than prefixing with the canonical server's own base path, removing the need to resolve "which declared server" at runtime. * fix(binding-mcp-openapi): drop stale 4-arg OpenapiView.of(...) call OpenapiView.of dropped its trailing List<OpenapiServerConfig> parameter when OpenapiServerView was made pure (713dcd4), but this call site was never updated and always passed an empty list for it — a no-op that only now surfaced as a compile break with the plain 3-arg overload in scope. Drop the extra argument; behavior is unchanged. * refactor(common-asyncapi): drop vestigial server-index from AsyncapiCompositeId AsyncapiCompositeId carried the same bit-packed server-index dimension that OpenapiCompositeId had before it caused a real correctness bug (#2145) -- but here it was always dead: no production code ever called the 3-arg constructor or read serverIndex(), since AsyncapiOperationView has no per-operation canonical-server concept to disambiguate in the first place. Removing it now so the shape can't be reused the same broken way if per-channel server scoping (see #2150) is ever added. * Revert "refactor(common-asyncapi): drop vestigial server-index from AsyncapiCompositeId" This reverts commit 2042e3d. * Reapply "refactor(common-asyncapi): drop vestigial server-index from AsyncapiCompositeId" This reverts commit e6c8c27. * fix(binding-asyncapi): wire per-operation servers into when.servers[] routing Swap the three call sites that fed the coarse, spec-wide server list into AsyncapiConditionConfig/AsyncapiBindingConfig.resolve for the real, per-operation-scoped list added by #2151: AsyncapiProxyGenerator's generation-time route matching, and AsyncapiServerFactory/AsyncapiProxyFactory's runtime route dispatch. A channel scoped to a subset of a spec's servers now correctly excludes routes whose when.servers[] condition targets a different server. Realign the composite/asyncapi mqtt and kafka k3po fixtures' hardcoded compositeId literals with AsyncapiCompositeId's simplified 2-field (specIndex, operationId) encoding now that the vestigial server-index dimension is gone. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * test(binding-asyncapi): add overlay k3po IT, trim generator unit tests Add a new AsyncapiServerIT scenario (shouldPublishToChannelAddedByOverlay) proving AsyncapiServerGenerator applies an options.specs.*.overlay document before generating routes, using a channel/operation only present after the overlay merge. Existing shouldPublishAndSubscribe/shouldPublishAndSubscribeWithStore already exercise configured-vs-default MQTT store selection end to end, so those two AsyncapiServerGeneratorTest cases are redundant and removed. Trim AsyncapiServerGeneratorTest, AsyncapiProxyGeneratorTest, and AsyncapiClientGeneratorTest down to only the assertions that have no reasonable k3po IT equivalent, documenting the specific blocker on each class: an attach-time exception message with no IT-visible surface, a servers[]-scoping condition only reachable via an internal-composite-origin dispatch path with no k3po test harness support for kind: proxy, and Kafka SASL/TLS/host-port wiring that only takes effect on a real outbound broker connection the existing IT intentionally bypasses. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * fix(binding-asyncapi): canonicalize HTTP/SSE server pathname; fix combination bug AsyncapiServerGenerator never combined a declared server's pathname (servers.*.pathname) with the channel address when generating HTTP/SSE request paths and routes, so a spec-compliant client prefixing requests with that pathname would 404. Fix by prepending the resolved pathname(s) to the channel address in injectHttpRequests/injectHttpRoutes/injectSseRequests/ injectSseRoutes. Also canonicalize the HTTP/SSE inner extension at AsyncapiServerFactory's exit (strip :scheme/:authority, rewrite path to the canonical channel address template) and un-canonicalize it at AsyncapiClientFactory's entry (reapply the resolved server URI and pathname), mirroring the existing OpenapiServerFactory/OpenapiClientFactory canonicalization. MQTT carries no non-relocatable server info in its BeginEx and is left untouched (already covered by existing byte-for-byte MQTT scripts). Update existing HTTP/SSE k3po fixtures to reflect the new canonical form and add new pathname-specific server/client ITs. * fix(binding-asyncapi.spec): align SSE peer-to-peer script with canonical form AsyncapiSseIT runs asyncapi/sse/data.multiple/client and /server directly against each other without Zilla, so both sides must already agree on the canonical (stripped scheme/authority) SseBeginEx shape now that AsyncapiServerFactory canonicalizes it. Only the server-side matcher was updated previously; align the client-side builder to match, fixing the CI failure on PR #2152. Also add the missing peer-to-peer IT coverage for the new create.pet.pathname scenario in AsyncapiHttpIT/CompositeHttpIT, per the one-scenario-needs-both-a-binding-IT-and-a-peer-to-peer-IT convention. * fix(examples): add required server/servers config to openapi/asyncapi examples The openapi and asyncapi binding schemas require options.specs.*.server (asyncapi, singular string) or options.specs.*.servers (openapi, array), but several example configs predate that requirement and were missing it entirely, so Zilla failed engine config validation on startup. Verified all seven openapi/asyncapi examples end-to-end against a locally built image from this branch: openapi.proxy, openapi.asyncapi.kakfa.proxy, asyncapi.http.kafka.proxy (sync + async flows), asyncapi.mqtt.kafka.proxy, asyncapi.mqtt.proxy, asyncapi.sse.kafka.proxy, asyncapi.sse.proxy. * fix(binding-asyncapi): use options.specs.*.servers (plural) for consistency with openapi Aligns the asyncapi binding's server override config with the already-migrated openapi binding shape: options.specs.<label>.server (single string) becomes options.specs.<label>.servers (array, minItems 1, required). - AsyncapiSpecificationConfig.servers is now a List<String>; the builder's serverOverride(String) accumulates repeated calls into that list - AsyncapiCompositeGenerator builds one AsyncapiServerConfig per configured server and cross-products them against the AsyncAPI document's own declared servers, same as before but generalized from exactly one entry - AsyncapiBindingConfig.resolveServers(specLabel) resolves the configured URIs, mirroring OpenapiBindingConfig.resolveBaseURLs - AsyncapiClientFactory now round-robins across multiple configured servers per (bindingId, specLabel) when resolving the HTTP/SSE un-canonicalize target, mirroring OpenapiClientFactory.selectServer - Updated the asyncapi JSON schema patch and every spec/example fixture referencing the old singular server: key * fix(binding-openapi-asyncapi): stop re-prefixing route-match path with server base path http_kafka_proxy0's route condition combined the OpenAPI document's declared server base path into its :path match, even though by the time a request reaches this internal route, openapi_server0 has already canonicalized :path down to the bare operation path. Match on the bare path instead. Updates the two script pairs that connect directly to composite0 (bypassing the canonicalizing server) to send/expect the now-bare path; their Location header values, produced independently by the async-produce config, are unaffected. * fix(binding-http-kafka): correlate correlater flow-control state to its own domain, not the shared delegate's KafkaCorrelateProxy.onKafkaReset compared and wrote delegate.initialAck, a field shared with the sibling KafkaProduceProxy. When an async POST's produce leg advances delegate.initialAck (via its own window accounting) after the correlater's begin-time snapshot, the fetch-domain reset acknowledge no longer satisfies delegate.initialAck's invariant, crashing the worker. Compare/write the correlater's own local initialAck/initialSeq instead, matching its sibling onKafkaWindow. * feat(binding-openapi): un-canonicalize response Location header at server exit Issue #2145 asks to canonicalize/un-canonicalize both request path and location values. OpenapiServerFactory already canonicalized the request path but passed the reply-direction Location header straight through in bare, canonical form, never reapplying the deployment's configured server path prefix. Add OpenapiBindingConfig.resolveServer (finds which configured options.specs.*.servers[] entry the real incoming request matched) and resolveLocation (reapplies that server's path prefix onto a bare Location header). OpenapiServerFactory's OpenapiStream stores the matched server as a plain per-stream field, set in the request-direction doOpenapiBegin and read back in the reply-direction onOpenapiBegin, since one OpenapiStream instance already handles both directions of the same exchange. * feat(binding-asyncapi): un-canonicalize response Location header at server exit Mirrors the OpenAPI-side fix for issue #2145's location-values half. AsyncapiServerFactory canonicalized the request path but passed the reply-direction Location header straight through in bare, canonical form, never reapplying the operation's declared server pathname. Add AsyncapiBindingConfig.resolveLocation (HTTP-only, gated the same way as canonicalize/resolve dispatch on SSE having no Location semantics), prepending the resolved pathname onto a bare Location header. Promote resolvePathname from AsyncapiClientFactory's private static helper to a shared AsyncapiBindingConfig method so AsyncapiServerFactory can reuse it; AsyncapiClientFactory now delegates to it instead of keeping its own copy. AsyncapiServerFactory threads the resolved pathname through AsyncapiStream and calls resolveLocation in the reply-direction onAsyncapiBegin. * fix(binding-openapi-asyncapi): fix flow-control relay bugs and stale correlation-id matcher unblocking shouldVerifyCustomerAsync Route-matching fix in 05179aa let shouldVerifyCustomerAsync's async produce/correlate/fetch path execute for the first time, surfacing several latent bugs it never previously reached: - CompositeClientStream.doCompositeWindow relayed replyPad into an initial-direction window, and doCompositeFlush used the wrong-domain budgetId; both are no-op violations on what should be a transparent relay - HttpKafkaProxyFactory: missing `+ reserved` on two FLUSH sequence trackers, a parameter-order swap in doKafkaEndAck, and a missing correlater window refresh in onHttpWindow - The correlate-listener's advisory flush never reached the wire because the correlation-id embedded in its filter no longer matched the request's canonical :path (see below), so the k3po script never got past its begin match; test fixtures hardcoded the stale pre-canonicalization hash Root cause of the correlation-id mismatch, and of getVerifiedCustomer being misrouted through HttpProduceAsyncProxy instead of HttpCorrelateAsyncProxy (producing a 400 instead of 204): OpenapiAsyncapiProxyGenerator still built the GET's correlation-id extraction regex from httpServer.requestPath(v.schema.format), which re-prepends the server's path prefix. Everything internal to the composite operates on canonical, prefix-stripped paths -- 05179aa fixed the route-match path but missed this second call site, so the regex could never match the canonical :path it actually sees at runtime, correlation-id extraction failed, and the code fell back to generating a random idempotency key. Fixed by building the matcher from the bare v.schema.format. Updated the .rpt fixtures' stale correlation-id hash and Location prefix to match. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * fix(binding-openapi-asyncapi): drop vestigial per-server route duplication injectHttpKafkaRoute looped over httpOp.servers to generate one route per declared OpenAPI spec-server, threading the OpenapiServerView through to injectHttpKafkaRouteWith/FetchWith/ProduceWith. None of those methods used it once route-path canonicalization removed the last httpServer.requestPath call, so the loop only produced duplicate, byte-for-byte identical routes per spec-server. Collapse it to generate the route once per operation. * refactor(common-asyncapi): purify AsyncapiServerView, drop config baking AsyncapiServerView took an AsyncapiServerConfig at construction and baked a deployment override into .url/.host/.pathname, while separately computing config-independent literalUrl/literalHost/literalPathname fields for when.servers[] route matching. Drop the config parameter entirely -- .url/.host/.pathname now always resolve to the spec's own declared default, identical to what the literal* fields used to compute, so the separate fields become redundant. Mirrors the same purification already done on OpenapiServerView. AsyncapiView/AsyncapiCompositeId no longer take or cross a List<AsyncapiServerConfig>; delete AsyncapiServerConfig/ AsyncapiServerConfigBuilder outright, matching the OpenAPI side (no OpenapiServerConfig equivalent exists there either). * refactor(binding-asyncapi,binding-openapi-asyncapi): drop config crossing at AsyncapiView.of Follows the AsyncapiServerView purification -- neither composite generator needs to build an AsyncapiServerConfig list anymore since the view no longer takes one. * refactor(binding-asyncapi): match when.servers[].url against pure .url server.literalUrl no longer exists; server.url now computes the exact same config-independent value directly, since the view is pure. Deletes shouldMatchServerByLiteralUrlRegardlessOfOverride -- its premise (comparing an overridden view against a literal one) is gone by construction; the invariant it proved is redundant with existing spec-variable-default coverage. * refactor(binding-asyncapi): fan out AsyncapiServerGenerator over resolveServers() TCP listener ports, plain/secure TCP routing, TLS SNI routes, and protocol-family dispatch used to read .port/.hostname/.protocol off the config-crossed AsyncapiServerView list. Now that the view is pure, these fan out over AsyncapiBindingConfig.resolveServers(specLabel) instead -- a List<URI> parsed directly from options.specs.*.servers[], deriving plain-vs-secure and protocol-family dispatch from URI.getScheme() rather than the spec's own protocol field. Mirrors OpenapiServerGenerator's resolveServers() pattern exactly; AsyncapiClientGenerator/ AsyncapiClientFactory already worked this way. resolvePathnames(operation) is untouched -- it correctly continues reading operation.servers/.protocol/.pathname off the now-pure view, since neither field was ever affected by config baking in practice. AsyncapiServerGeneratorTest.shouldPopulateTlsAuthorityForSniRouting needs an explicit serverOverride now that resolveServers() is the source of TLS listener ports/authorities. * fix(binding-asyncapi.spec): scheme-prefix server-side options.specs.*.servers[] resolveServers() parses each entry via URI.create, which needs a scheme to correctly extract host:port -- a schemeless "host:port" string parses as an opaque URI (host becomes the scheme) rather than an authority. Client-side fixtures already used scheme-prefixed strings; server-side ones were bare. Scheme-prefix every server-side fixture to match its own already-declared spec-level protocol. No behavior change -- resolved ports/hosts are numerically identical, only the parsing mechanism changed. * refactor(common-asyncapi,binding-asyncapi): parse AsyncapiServerView address as one URI AsyncAPI 3.0 splits what 2.x expressed as a single `url` into `host` (may include port) + `protocol` + `pathname`, intended to reconstruct as `{protocol}://{host}{pathname}`. AsyncapiServerView kept these as four separate fields instead (url, host, hostname, port), with hostname/port derived through a synthetic "tcp://"+host wrapper that ignored both the real protocol and pathname. All four had zero consumers left outside the view's own constructor -- orphaned once TCP/TLS generation moved to resolveServers() earlier in this branch's history. Replace them with a single `url` (URI), composed from host+protocol+ pathname for 3.0-style documents or parsed directly for legacy 2.x `url` declarations, mirroring OpenapiServerView.url exactly. pathname/protocol stay as their own fields -- pathname because URI.getPath() would turn a genuinely-absent pathname into "" instead of null, changing existing nonNull-filtering behavior in AsyncapiBindingConfig.resolvePathname/ AsyncapiServerGenerator.resolvePathnames; protocol because its call sites are clearer than .url.getScheme() would be. This also fixes a real bug: AsyncapiConditionServerConfig.matches (the when.servers[].url route filter) compared against the legacy url string, which is always null for a spec-compliant 3.0 document (host+protocol documents have no url property at all per the AsyncAPI 3.0 schema) -- so when.servers[].url silently never matched on any 3.0 spec. Now compares against the composed URI's string form, working for both spec styles. * refactor(common-asyncapi,binding-asyncapi): fold pathname into AsyncapiServerView.url pathname was kept as its own field alongside the newly-unified url on the stated concern that URI.getPath() returns "" for a path-less hierarchical URI while pathname was null, and both consumers (AsyncapiBindingConfig.resolvePathname, AsyncapiServerGenerator's resolvePathnames) filtered on Objects::nonNull. On closer look that distinction wasn't protecting a real invariant -- both callers already fall back to "" at the end regardless, and the null-filter's only actual effect was silently dropping a server that declares no pathname whenever another server for the same operation/spec does declare one, which is a bug (that server's un-prefixed route stops being generated), not a feature worth preserving. Folding also fixes a related latent gap: pathname was populated only from AsyncAPI 3.0's separate `pathname` field, so a legacy 2.x server declaring `url: https://host/v1` had its embedded /v1 path silently ignored for HTTP route generation. url.getPath() picks it up correctly regardless of which spec style produced it. protocol stays its own field (not url.getScheme()) -- it's the document's directly-declared value rather than something re-derived from a parsed URI, and its call sites read more clearly as .protocol. * refactor(common-asyncapi,binding-asyncapi): fold protocol into AsyncapiServerView.url protocol duplicated what url's own scheme already carries: for the host+protocol (3.0) branch, url is composed using model.protocol as the scheme directly, so url.getScheme() equals protocol by construction; for the legacy url-style branch, the declared protocol was a separately-trusted value alongside the address actually used for routing, rather than derived from it. Drop the field and read url.getScheme() at all four call sites instead (AsyncapiView.hasProtocol, AsyncapiBindingConfig.resolvePathname, AsyncapiServerGenerator's resolvePathnames, AsyncapiClientGenerator's protocol-family dispatch), so the address actually used for routing/generation is the single source of truth for its own scheme, with no separately-synthesized value to drift from it. * refactor(binding-asyncapi): rename resolvePathname(s) to resolvePath(s) AsyncapiServerView.url is now a single parsed URI, so these methods return a URI path component, not a legacy pathname string. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * refactor(binding-asyncapi): rename remaining pathname identifiers to path/serverPath AsyncapiServerGenerator's per-operation loop variables now read as plain URI path values (path). The deployment-path-prefix threaded through AsyncapiServerFactory/AsyncapiClientFactory/AsyncapiBindingConfig's resolve/resolveLocation family is renamed to serverPath to avoid colliding with the existing path parameter in requestPath(). Left untouched: AsyncapiServer.pathname (the AsyncAPI 3.0 Server Object's own JSON property name) and AsyncapiServerView's constructor locals that parse it directly. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k * fix(examples): fix flaky asyncapi.sse.proxy test race The sse-server test double broadcasts events live with no buffering: if curl's SSE subscription hasn't finished connecting through Zilla before the event is published via nc, it's lost for good. The old script backgrounded curl and published immediately, racing the subscription's HTTP/2 upgrade handshake — reproduced the same drop connecting straight to the sse-server, bypassing Zilla entirely. Wait for the subscription to establish before publishing, and retry the whole cycle using the shared retry_until helper, matching the pattern already used by other examples in .github/test-lib.sh. Verified locally: 6/6 clean passes after the fix, versus frequent failures before it. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HzJgppmUNpSfzpJbzgxf8k --------- 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
AsyncAPI 3.0's Channel Object supports an optional
serversproperty — an array of$refs into the document's top-levelserversmap, scoping a channel to a subset of the declared servers. Zilla's bundled JSON Schema already validates this property, butAsyncapiChannel(the deserialization target) had no field to receive it, so it was silently dropped and every channel/operation was treated as available on every server.This change:
serversfield toAsyncapiChannel.AsyncapiServerResolver(resolving#/servers/(.+)refs), wired intoAsyncapiResolveralongside the existing channel/message/schema resolvers, including unresolved-ref tracking for malformed docs.List<AsyncapiServerView>throughAsyncapiChannelViewandAsyncapiOperationView— a channel scoped to a server subset now returns only those servers; an unscoped channel falls back to every declared server, per the spec's stated semantics ("If absent or empty then this channel must be available on all servers").protocolVersion,title,summary,description,tagstoAsyncapiServer— fields the schema already allows and existing spec fixtures (client.http.yaml,client.kafka.yaml) already set, but were previously discarded for lack of a model field. Threaded through toAsyncapiServerView.Out of scope (left for a follow-up): wiring this into
binding-asyncapi'swhen.servers[]route condition /AsyncapiServerFactory's routing logic. That mechanism is currently a coarse per-spec filter, and making it genuinely per-operation needs its own design discussion to avoid the class of bug PR #2145 fixed on the OpenAPI side.Fixes #2150
Generated by Claude Code