fix: expose server title() on the server object v3#1200
Conversation
|
princerajpoot20
left a comment
There was a problem hiding this comment.
@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
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
|



Summary
Fixes #1075 by exposing
server.title()andserver.hasTitle()on the sharedServerInterfacefor v3 documents.Problem
The AsyncAPI 3.0 Server Object defines an optional
titlefield — a human-friendly name for the server. Users could not access it through the parser's typed API when retrieving servers viadocument.allServers().At runtime, v3
Serveralready inheritstitle()fromCoreModel. The issue was thatServerInterfacedid not declare these methods, so TypeScript consumers had no proper type support forserver.title().Why only
ServerInterfaceneeded a production changetitleon Server ObjectServerclasstitle()viaCoreModelServerInterfacetitle()/hasTitle()No changes to the v3
Serverimplementation were required. Only the shared TypeScript contract needed updating.Why v2 was not changed
titleon the Server Objecttitle()toServerInterfacewould force stub methods on v2ServerPartial<TitleMixinInterface>is used instead so:title()as expectedChanges
packages/parser/src/models/server.ts— extendServerInterfacewithPartial<TitleMixinInterface>packages/parser/test/models/v3/server.spec.ts— unit tests for.title()and absent titlepackages/parser/test/models/v3/asyncapi.spec.ts— testallServers()exposestitleandhasTitlepackages/parser/test/parse.spec.ts— v3 integration test fortitleviaparse()Test plan
title()passAsyncAPIDocument.allServers()test passesparse()integration test passes