Skip to content

feat(asyncapi): add Follow() to remaining referenceable types (#146) - #329

Merged
lerenn merged 1 commit into
mainfrom
feat/146-follow-methods
Jun 12, 2026
Merged

lerenn merged 1 commit into
mainfrom
feat/146-follow-methods

Conversation

@lerenn

@lerenn lerenn commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Issue

Fixes #146 — only some referenceable structures exposed a Follow() helper to resolve a $ref. Many v3 types with a ReferenceTo field (and v2 Parameter) lacked one, so callers had to special-case them.

Change

Adds a Follow() method (returns the referenced value if set, otherwise the receiver) to every remaining type that has a ReferenceTo:

  • v3: ChannelBindings, ExternalDocumentation, MessageBindings, MessageExample, OperationBindings, OperationReplyAddress, SecurityScheme, Server, ServerBindings, ServerVariable, Tag
  • v2: Parameter

This matches the pattern already used by Channel, Message, Operation, Schema, etc. Purely additive — go generate ./... produces no diff. (CorrelationID.ReferenceTo is typed *Channel, an anomaly left untouched here.)

Test

pkg/asyncapi/v3/follow_test.go and pkg/asyncapi/v2/follow_test.go assert Follow() returns the receiver when there is no reference and the referent when one is set. They fail to compile before the change (methods undefined) and pass after.

🤖 Generated with Claude Code

Several v3 types that carry a $ref (ChannelBindings, ExternalDocumentation,
MessageBindings, MessageExample, OperationBindings, OperationReplyAddress,
SecurityScheme, Server, ServerBindings, ServerVariable, Tag) and v2
Parameter had a ReferenceTo field but no Follow() helper. Add Follow() to
each so referenced structures can be resolved uniformly, matching the
types that already had it.

Fixes #146

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lerenn
lerenn force-pushed the feat/146-follow-methods branch from 564409a to a20ca6f Compare June 12, 2026 16:00
@lerenn
lerenn merged commit 1c43155 into main Jun 12, 2026
5 checks passed
@lerenn
lerenn deleted the feat/146-follow-methods branch June 12, 2026 16:04
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.

Every structure that have a reference should have a Follow() and its parents have a Get<structure>

1 participant