Skip to content

Commit

Permalink
feat: spec v3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Souvikns committed Oct 23, 2023
1 parent f0d7d84 commit 3e2886b
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 108 deletions.
40 changes: 24 additions & 16 deletions examples/crypto-websockets/client/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
asyncapi: 2.4.0
info:
asyncapi: 3.0.0
info:
title: asyncapicoin client
version: 1.0.0
description: |
This app creates a client that subscribes to the server for the price change.
description: >
This app creates a client that subscribes to the server for the price
change.
servers:
websockets:
url: ws://localhost:3000
host: 'localhost:3000'
protocol: ws
security:
- token: []
- userPass: []
- apiKey: []
- cert: []
x-remoteServers:
- websockets
- $ref: '#/components/securitySchemes/token'
- $ref: '#/components/securitySchemes/userPass'
- $ref: '#/components/securitySchemes/apiKey'
- $ref: '#/components/securitySchemes/cert'
channels:
/price:
address: /price
messages:
index.message:
$ref: '#/components/messages/indexGraph'
bindings:
ws:
bindingVersion: 0.1.0
publish:
operationId: index
message:
$ref: '#/components/messages/indexGraph'
operations:
index:
action: receive
channel:
$ref: '#/channels/~1price'
messages:
- $ref: '#/components/messages/indexGraph'
components:
messages:
indexGraph:
Expand All @@ -49,4 +55,6 @@ components:
in: header
cert:
type: apiKey
in: user
in: user
x-remoteServers:
- websockets
35 changes: 22 additions & 13 deletions examples/crypto-websockets/server/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
asyncapi: 2.4.0
asyncapi: 3.0.0
info:
title: asyncapicoin server
version: 1.0.0
description: |
This app is a dummy server that would stream the price of a fake cryptocurrency
description: >
This app is a dummy server that would stream the price of a fake
cryptocurrency
servers:
websocket:
url: ws://localhost:3000
host: 'localhost:3000'
protocol: ws
security:
- token: []
- userPass: []
- apiKey: []
- cert: []
- $ref: '#/components/securitySchemes/token'
- $ref: '#/components/securitySchemes/userPass'
- $ref: '#/components/securitySchemes/apiKey'
- $ref: '#/components/securitySchemes/cert'
ws-websocket:
url: ws://localhost:4000
host: 'localhost:4000'
protocol: ws
channels:
/price:
address: /price
messages:
subscribe.message:
$ref: '#/components/messages/indexGraph'
bindings:
ws:
bindingVersion: 0.1.0
Expand All @@ -26,9 +31,13 @@ channels:
properties:
token:
type: string
subscribe:
message:
$ref: '#/components/messages/indexGraph'
operations:
/price.subscribe:
action: send
channel:
$ref: '#/channels/~1price'
messages:
- $ref: '#/components/messages/indexGraph'
components:
messages:
indexGraph:
Expand All @@ -55,4 +64,4 @@ components:
in: header
cert:
type: apiKey
in: user
in: user
63 changes: 41 additions & 22 deletions examples/dummy/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
asyncapi: 2.0.0
asyncapi: 3.0.0
info:
title: Account Service
version: 1.0.0
description: This service is in charge of processing user signups
servers:
mosquitto:
url: mqtts://test.mosquitto.org
host: test.mosquitto.org
protocol: mqtts
security:
- X509Certificate: []
- $ref: '#/components/securitySchemes/X509Certificate'
bindings:
mqtt:
clientId: guest
cleanSession: true
keepAlive: 60
bindingVersion: 0.1.0
bindingVersion: 0.2.0
websockets:
url: ws://localhost:3005/ws
host: 'localhost:3005'
pathname: /ws
protocol: ws
channels:
user/signedup:
address: user/signedup
messages:
onUserSignedUp.message:
$ref: '#/components/messages/UserSignedUp'
subscribe.message:
$ref: '#/components/messages/UserSignedUp'
bindings:
ws:
bindingVersion: 0.1.0
Expand All @@ -35,24 +42,36 @@ channels:
properties:
my-custom-header:
type: string
const: 'custom value'

publish:
operationId: onUserSignedUp
message:
$ref: '#/components/messages/UserSignedUp'
bindings:
mqtt:
qos: 2
retain: true
bindingVersion: 0.1.0
subscribe:
message:
$ref: '#/components/messages/UserSignedUp'
const: custom value
server/announce:
subscribe:
message:
address: server/announce
messages:
subscribe.message:
$ref: '#/components/messages/ServerAnnounce'
operations:
onUserSignedUp:
action: receive
channel:
$ref: '#/channels/user~1signedup'
bindings:
mqtt:
qos: 2
retain: true
bindingVersion: 0.2.0
messages:
- $ref: '#/components/messages/UserSignedUp'
user/signedup.subscribe:
action: send
channel:
$ref: '#/channels/user~1signedup'
messages:
- $ref: '#/components/messages/UserSignedUp'
server/announce.subscribe:
action: send
channel:
$ref: '#/channels/server~1announce'
messages:
- $ref: '#/components/messages/ServerAnnounce'
components:
securitySchemes:
userAndPassword:
Expand Down Expand Up @@ -98,4 +117,4 @@ components:
- id
properties:
id:
type: string
type: string
74 changes: 40 additions & 34 deletions examples/shrek-websockets/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
asyncapi: 2.0.0

#
# Overal information for users of the application
#
asyncapi: 3.0.0
info:
title: Shrek App
version: '1.0.0'
description: |
Purpose of this app is to have some fun with AsyncAPI and WebSocket and define an interface for ... Shrek.
version: 1.0.0
description: >
Purpose of this app is to have some fun with AsyncAPI and WebSocket and
define an interface for ... Shrek.
![](https://media.giphy.com/media/10Ug6rDDuG3YoU/giphy-downsized.gif)
You can use this API to chat with Shrek bot or to get updates about artifical travels to different locations.
#
# Details on how to connect to the application
#
You can use this API to chat with Shrek bot or to get updates about
artifical travels to different locations.
servers:
swamp:
url: ws://localhost
host: localhost
protocol: ws

#
# Details about all the channels that you can listen to or send to messages
#
channels:
/chat:
subscribe:
summary: Client can receive chat messages.
operationId: subChatMessage
message:
address: /chat
messages:
pubChatMessage.message:
$ref: '#/components/messages/chatMessage'
publish:
summary: Client can send chat messages.
operationId: pubChatMessage
message:
subChatMessage.message:
$ref: '#/components/messages/chatMessage'
/travel/status:
subscribe:
summary: Client can receive travel info status.
operationId: subTravelInfo
message:
address: /travel/status
messages:
subTravelInfo.message:
$ref: '#/components/messages/travelInfo'

#
# All reusable parts for readability and staying DRY
#
operations:
pubChatMessage:
action: receive
channel:
$ref: '#/channels/~1chat'
summary: Client can send chat messages.
messages:
- $ref: '#/components/messages/chatMessage'
subChatMessage:
action: send
channel:
$ref: '#/channels/~1chat'
summary: Client can receive chat messages.
messages:
- $ref: '#/components/messages/chatMessage'
subTravelInfo:
action: send
channel:
$ref: '#/channels/~1travel~1status'
summary: Client can receive travel info status.
messages:
- $ref: '#/components/messages/travelInfo'
components:
messages:
chatMessage:
Expand All @@ -69,4 +75,4 @@ components:
type: string
arrival:
description: Time left to get there.
type: string
type: string
19 changes: 12 additions & 7 deletions examples/social-network/notifications-service/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
asyncapi: 2.2.0
asyncapi: 3.0.0
info:
title: Notifications Service
version: 0.1.0

servers:
mosquitto:
url: mqtt://test.mosquitto.org
host: test.mosquitto.org
protocol: mqtt
bindings:
mqtt:
clientId: notifications-service

channels:
post/liked:
publish:
operationId: onPostLiked
message:
address: post/liked
messages:
onPostLiked.message:
$ref: '../websocket-server/asyncapi.yaml#/components/messages/notifyPostLiked'
operations:
onPostLiked:
action: receive
channel:
$ref: '#/channels/post~1liked'
messages:
- $ref: '#/channels/post~1liked/messages/onPostLiked.message'
Loading

0 comments on commit 3e2886b

Please sign in to comment.