Fix AsyncAPI 3.0 Channel Parameters Referenced with $ref - #923
Closed
Levyks wants to merge 1 commit into
Closed
Conversation
mwadams
added a commit
that referenced
this pull request
Aug 10, 2026
…I generators (#929) * Fix AsyncAPI referenced channel parameters * Fix #924: resolve $ref at every referenceable position in the AsyncAPI generators AsyncAPI 3.0 allows a Reference Object at nearly every position, but the generator's Match calls silently dropped references at most of them: top-level channels, operations, and servers entries, server variables, the channel entity behind an operation's channel reference (whose fallback subscribed the generated consumer to the channel key instead of the real address), the channel/operation/message entities in GetBindings, message bindings expressed as a reference, and security scheme entries that alias another scheme. Each site now resolves through the shared ResolveRef chain first, via a TryResolveEntry helper that treats a still-unresolved reference like a malformed entry. The one deliberate non-resolving site (channel messages in CollectSchemaPointers, which are collected separately from components) now says so explicitly. The AsyncAPI 2.6 generator's CollectChannelParameters reads the parameter and its schema through ResolveRef too, so a referenced parameter's description, enum, and default survive rather than silently degrading to a bare argument. ListOperations and ListServers gain an optional reference resolver parameter for external references, matching CollectSchemaPointers and GetBindings. The referenced-components fixture drives twelve regression tests covering every swept site, including generated-output compilation; all failed against the unfixed generator. Builds on #923, which fixed the channel-parameter instance of this class for 3.0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0157Tdszg6wzgWeKgGYRBNKV * Add generation diagnostics and an asyncapi-generate --strict flag Generation stays deliberately lenient, but a reference the generator cannot use is no longer silent: every swept site records an AsyncApiGenerationDiagnostic (severity, specification location, what the generator did instead), exposed as a Diagnostics property on both generators and collectable from the public static helpers via an optional parameter. The CLI prints each diagnostic as a warning after generation, and a new --strict option fails the run when any were produced. A dangling-reference fixture proves the intact operation still generates, exactly one diagnostic is recorded with its location, a clean spec records none, and the CLI exits 0 with the warning printed (or 1 under --strict). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0157Tdszg6wzgWeKgGYRBNKV * Add the V5.3.2 version history entry Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0157Tdszg6wzgWeKgGYRBNKV --------- Co-authored-by: Levy Barbosa <marcio.levy20@gmail.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.
PR #915 implemented generated arguments for templated channel addresses through the common inline-parameter path. However, channel parameters represented with
$refwere still ignored during code generation.For example, this worked:
But this did not generate the
orderIdargument:The generator handled the channel reference itself, but did not resolve references for individual entries in
channel.parameters. As a result, referenced parameters were treated as undefined and the generated consumer used the literal templated address.This change resolves each channel parameter before extracting its metadata, preserving support for both inline and referenced parameters.
Added regression coverage for the referenced-parameter case while retaining the existing inline-parameter coverage.
All 184 AsyncAPI code-generation tests pass.