Skip to content

fix: expose server title() on the server object v3#1200

Merged
princerajpoot20 merged 5 commits into
asyncapi:masterfrom
AayushSaini101:1075
Jul 17, 2026
Merged

fix: expose server title() on the server object v3#1200
princerajpoot20 merged 5 commits into
asyncapi:masterfrom
AayushSaini101:1075

Conversation

@AayushSaini101

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1075 by exposing server.title() and server.hasTitle() on the shared ServerInterface for v3 documents.

Problem

The AsyncAPI 3.0 Server Object defines an optional title field — a human-friendly name for the server. Users could not access it through the parser's typed API when retrieving servers via document.allServers().

At runtime, v3 Server already inherits title() from CoreModel. The issue was that ServerInterface did not declare these methods, so TypeScript consumers had no proper type support for server.title().

Why only ServerInterface needed a production change

Layer Status
AsyncAPI v3 spec Defines optional title on Server Object
v3 Server class Already implements title() via CoreModel
Parsing / runtime Already worked
ServerInterface Did not declare title() / hasTitle()

No changes to the v3 Server implementation were required. Only the shared TypeScript contract needed updating.

Why v2 was not changed

  • AsyncAPI v2 does not define title on the Server Object
  • Adding required title() to ServerInterface would force stub methods on v2 Server
  • Partial<TitleMixinInterface> is used instead so:
    • v3 servers expose title() as expected
    • v2 servers remain unchanged and spec-accurate

Changes

  • packages/parser/src/models/server.ts — extend ServerInterface with Partial<TitleMixinInterface>
  • packages/parser/test/models/v3/server.spec.ts — unit tests for .title() and absent title
  • packages/parser/test/models/v3/asyncapi.spec.ts — test allServers() exposes title and hasTitle
  • packages/parser/test/parse.spec.ts — v3 integration test for title via parse()

Test plan

  • v3 Server model unit tests for title() pass
  • v3 AsyncAPIDocument.allServers() test passes
  • v3 parse() integration test passes
  • TypeScript build passes with no v2 changes

@changeset-bot

changeset-bot Bot commented Jul 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 221f190

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@princerajpoot20 princerajpoot20 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AayushSaini101
changes in this PR and in PR #1199 seems overlapping. can you have a look at it.

also can you please add tests for these

@sonarqubecloud

Copy link
Copy Markdown

@princerajpoot20 princerajpoot20 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@princerajpoot20
princerajpoot20 merged commit d4ad148 into asyncapi:master Jul 17, 2026
10 checks passed
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.

[BUG] Missing server.title() function

2 participants