DISCLAIMER: Not native at JS, code has not been tested. Just an illustrative example.
Examples for the Parser Intent-driven API.
Channels
Intents
-
asyncapi.channelsApplicationPublishesTo()
->asyncapi.channels().filter(channel => channel.hasSubscribe())
-
asyncapi.channelsApplicationSubscribeTo()
->asyncapi.channels().filter(channel => channel.hasPublish())
-
asyncapi.channelsClientCanPublishTo()
->asyncapi.channels().filter(channel => channel.hasPublish())
-
asyncapi.channelsClientCanSubscribeTo()
->asyncapi.channels().filter(channel => channel.hasSubscribe())
-
asyncapi.messagesApplicationPublishesTo()
->asyncapi.channelsApplicationPublishesTo().map(function(channel) {return channel.subscribe().message};)
-
asyncapi.messagesApplicationSubscribeTo()
->asyncapi.channels().filter(channel => channel.hasPublish()).map(function(channel) {return channel.publish().message};)
-
asyncapi.messagesClientCanPublishTo()
->asyncapi.channels().filter(channel => channel.hasPublish()).map(function(channel) {return channel.publish().message};)
-
asyncapi.messagesClientCanSubscribeTo()
->asyncapi.channels().filter(channel => channel.hasSubscribe()).map(function(channel) {return channel.subscribe().message};)
Getters (we still keep them)
message.getOperations()
(Due to the current spec, only one operation is linked to a particular message)message.getPayload()
Servers
asyncapi.bindings('kafka')
-> Return all the bindings from all possible places:- servers
- channels
- operations
- messages
asyncapi.bindings('kafka', 'servers')
-> Return kafka binding for serversasyncapi.bindings('kafka', 'servers', 'name-of-server1', 'name-of-server2')
-> Return kafka binding for specific servers