Skip to content

Fix AsyncAPI 3.0 Channel Parameters Referenced with $ref - #923

Closed
Levyks wants to merge 1 commit into
corvus-dotnet:mainfrom
Levyks:fix/asyncapi-ref-parameter-generation
Closed

Fix AsyncAPI 3.0 Channel Parameters Referenced with $ref#923
Levyks wants to merge 1 commit into
corvus-dotnet:mainfrom
Levyks:fix/asyncapi-ref-parameter-generation

Conversation

@Levyks

@Levyks Levyks commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

PR #915 implemented generated arguments for templated channel addresses through the common inline-parameter path. However, channel parameters represented with $ref were still ignored during code generation.

For example, this worked:

channels:
  orders:
    address: orders.{orderId}.created
    parameters:
      orderId:
        description: The order identifier.

But this did not generate the orderId argument:

components:
  parameters:
    OrderId:
      description: The order identifier.

channels:
  orders:
    address: orders.{orderId}.created
    parameters:
      orderId:
        $ref: '#/components/parameters/OrderId'

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.

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>
@mwadams mwadams closed this Aug 10, 2026
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