nestjs-asyncapi icon indicating copy to clipboard operation
nestjs-asyncapi copied to clipboard

Implement support for AsyncApi 2.3.0

Open pavlikm opened this issue 2 years ago • 2 comments

AsyncApi 2.3.0 was released few days ago: https://www.asyncapi.com/blog/release-notes-2.3.0 which allows "Servers and channels can now be defined as reusable components". It would be great to implement some "server" key into AsyncApiPub() and AsyncApiSub() decorators

pavlikm avatar Feb 24 '22 16:02 pavlikm

hey @pavlikm, can u give an example of server key usage in AsyncApiX() decorators?

  • yaml example with server key would be nice

flamewow avatar Mar 27 '22 18:03 flamewow

@flamewow I have defined servers in nestjs application like this:

const asyncApiOptions = new AsyncApiDocumentBuilder()
        .setTitle('...')
        .setDescription('...')
        .setVersion('1.0')
        .setDefaultContentType('application/json')
        .addServer('messaging', messagesServer)
        .addServer('users', userServer)
        .addServer('system', systemServer)
        .addServer('notifications', notificationsServer)
        .build()

where notifications, systemServer, userServer and messagesServer are of type AsyncServerObject. So it would be great, If I could define server in AsyncApiPub() and AsyncApiSub() decorators like this:

@AsyncApiPub({
    channel: Events.GET_PRIVATE_CONVERSATION_MESSAGES,
    summary: '...',
    description: '...',
    tags: [{name: "messaging"}],
    server: messagesServer,
    message: {
      name: 'GetPrivateConversationMessages',
      payload: {
        type: () => GetPrivateConversationMessages,
      },
    },
  })

pavlikm avatar Apr 06 '22 06:04 pavlikm

stale1

flamewow avatar Oct 06 '22 09:10 flamewow