Skip to content

Commit cc109fe

Browse files
authored
docs: update examples to be written by human not converter (#977)
1 parent abfae49 commit cc109fe

26 files changed

+312
-260
lines changed

examples/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,14 @@
22

33
In this directory, you can find some examples of AsyncAPI documents.
44

5-
**Do you have an example that could be valuable?** Open a pull request to contribute it.
5+
**Do you have an example that could be valuable?** Open a pull request to contribute it.
6+
7+
## File naming
8+
9+
You may notice `asyncapi` in the the name of each example. We recommend doing the same with your AsyncAPI document. This way you enable features like documentation display on node hover, auto completion and validation of your AsyncAPI documents in IDEs like VSCode or IntelliJ IDEA. IDEs integrate with [SchemaStore](https://www.schemastore.org/json/) where AsyncAPI specification JSON Schema files are referenced. Some IDEs do it by default, some, like VSCode require you to install additional extensions, like `YAML` extension.
10+
11+
## Editors
12+
13+
To edit your AsyncAPI documents, you can use [AsyncAPI Studio](https://studio.asyncapi.com/).
14+
15+
If you prefer to use your favourite IDE, there are official extensions for [VSCode](https://marketplace.visualstudio.com/items?itemName=asyncapi.asyncapi-preview) and [IntelliJ IDEA](https://plugins.jetbrains.com/plugin/15673-asyncapi)
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ components:
3333
type: object
3434
properties:
3535
key2:
36-
type: string
36+
type: string
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ servers:
2020
- '1883'
2121
- '8883'
2222
channels:
23-
'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured':
23+
lightingMeasured:
2424
address: 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured'
2525
messages:
26-
receiveLightMeasurement.message:
26+
lightMeasured:
2727
$ref: '#/components/messages/lightMeasured'
2828
parameters:
2929
streetlightId:
@@ -32,8 +32,7 @@ operations:
3232
receiveLightMeasurement:
3333
action: receive
3434
channel:
35-
$ref: >-
36-
#/channels/smartylighting~1streetlights~11~10~1event~1{streetlightId}~1lighting~1measured
35+
$ref: '#/channels/lightingMeasured'
3736
summary: >-
3837
Inform about environmental lighting conditions of a particular
3938
streetlight.
@@ -84,4 +83,4 @@ components:
8483
type: string
8584
parameters:
8685
streetlightId:
87-
description: The ID of the streetlight.
86+
description: The ID of the streetlight.
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ servers:
5656
- 'streetlights:dim'
5757
- $ref: '#/components/securitySchemes/openIdConnectWellKnown'
5858
channels:
59-
'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured':
59+
lightingMeasured:
6060
address: 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured'
6161
messages:
62-
receiveLightMeasurement.message:
62+
lightMeasured:
6363
$ref: '#/components/messages/lightMeasured'
6464
parameters:
6565
streetlightId:
6666
$ref: '#/components/parameters/streetlightId'
67-
'smartylighting/streetlights/1/0/action/{streetlightId}/dim':
67+
lightsDim:
6868
address: 'smartylighting/streetlights/1/0/action/{streetlightId}/dim'
6969
messages:
70-
dimLight.message:
70+
dimLight:
7171
$ref: '#/components/messages/dimLight'
7272
parameters:
7373
streetlightId:
@@ -76,8 +76,7 @@ operations:
7676
receiveLightMeasurement:
7777
action: receive
7878
channel:
79-
$ref: >-
80-
#/channels/smartylighting~1streetlights~11~10~1event~1{streetlightId}~1lighting~1measured
79+
$ref: '#/channels/lightingMeasured'
8180
summary: >-
8281
Inform about environmental lighting conditions of a particular
8382
streetlight.
@@ -86,8 +85,7 @@ operations:
8685
dimLight:
8786
action: send
8887
channel:
89-
$ref: >-
90-
#/channels/smartylighting~1streetlights~11~10~1action~1{streetlightId}~1dim
88+
$ref: '#/channels/lightsDim'
9189
messages:
9290
- $ref: '#/components/messages/dimLight'
9391
components:
@@ -179,4 +177,4 @@ components:
179177
'streetlights:dim': Ability to dim the lights
180178
openIdConnectWellKnown:
181179
type: openIdConnect
182-
openIdConnectUrl: 'https://authserver.example/.well-known'
180+
openIdConnectUrl: 'https://authserver.example/.well-known'
Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ servers:
1212
security:
1313
- $ref: '#/components/securitySchemes/httpBearerToken'
1414
channels:
15-
'/rooms/{roomId}/{resource}':
15+
rooms:
1616
address: '/rooms/{roomId}/{resource}'
1717
messages:
18-
subscribe.message.0:
18+
chatMessage:
1919
$ref: '#/components/messages/chatMessage'
20-
subscribe.message.1:
20+
heartbeat:
2121
$ref: '#/components/messages/heartbeat'
2222
parameters:
2323
roomId:
@@ -30,10 +30,10 @@ channels:
3030
- events
3131
description: The resource to consume.
3232
operations:
33-
'/rooms/{roomId}/{resource}.subscribe':
33+
sendRoomInfo:
3434
action: send
3535
channel:
36-
$ref: '#/channels/~1rooms~1{roomId}~1{resource}'
36+
$ref: '#/channels/rooms'
3737
bindings:
3838
http:
3939
type: response
@@ -148,7 +148,15 @@ components:
148148
description: Stands for "Gravatar version" and is used for cache busting.
149149
bindings:
150150
http:
151-
$ref: '#/components/messageBindings/streamingHeaders'
151+
headers:
152+
type: object
153+
properties:
154+
Transfer-Encoding:
155+
type: string
156+
const: chunked
157+
Trailer:
158+
type: string
159+
const: \r\n
152160
heartbeat:
153161
summary: Its purpose is to keep the connection alive.
154162
payload:
@@ -159,10 +167,12 @@ components:
159167
- "\r\n"
160168
bindings:
161169
http:
162-
$ref: '#/components/messageBindings/streamingHeaders'
163-
messageBindings:
164-
streamingHeaders:
165-
http:
166-
headers:
167-
Transfer-Encoding: chunked
168-
Trailer: \r\n
170+
headers:
171+
type: object
172+
properties:
173+
Transfer-Encoding:
174+
type: string
175+
const: chunked
176+
Trailer:
177+
type: string
178+
const: \r\n

examples/kraken-websocket-request-reply-message-filter-in-reply.yml renamed to examples/kraken-websocket-request-reply-message-filter-in-reply-asyncapi.yml

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,76 +36,107 @@ channels:
3636
$ref: '#/components/messages/subscribe'
3737
unsubscribe:
3838
$ref: '#/components/messages/unsubscribe'
39+
dummyCurrencyInfo:
40+
$ref: '#/components/messages/dummyCurrencyInfo'
3941

4042

4143
operations:
42-
pingPong:
43-
action: send
44+
receivePing:
45+
action: receive
4446
channel:
4547
$ref: '#/channels/currencyExchange'
4648
reply:
4749
channel:
4850
$ref: '#/channels/currencyExchange'
4951
messages:
50-
- $ref: '#/components/messages/ping'
51-
heartbeat:
52-
action: receive
52+
- $ref: '#/components/messages/pong'
53+
messages:
54+
- $ref: '#/components/messages/ping'
55+
sendHeartbeat:
56+
action: send
5357
channel:
54-
$ref: '#/channels/currencyExchange'
58+
$ref: '#/channels/currencyExchange'
59+
messages:
60+
- $ref: '#/components/messages/heartbeat'
5561
systemStatus:
56-
action: receive
57-
channel:
58-
$ref: '#/channels/currencyExchange'
59-
subscribe:
6062
action: send
63+
channel:
64+
$ref: '#/channels/currencyExchange'
65+
messages:
66+
- $ref: '#/components/messages/systemStatus'
67+
receiveSubscribeRequest:
68+
action: receive
6169
channel:
6270
$ref: '#/channels/currencyExchange'
6371
reply:
6472
channel:
6573
$ref: '#/channels/currencyExchange'
6674
messages:
6775
- $ref: '#/components/messages/subscriptionStatus'
68-
unsubscribe:
69-
action: send
76+
- $ref: '#/components/messages/dummyCurrencyInfo'
77+
messages:
78+
- $ref: '#/components/messages/subscribe'
79+
receiveUnsubscribeRequest:
80+
action: receive
7081
channel:
7182
$ref: '#/channels/currencyExchange'
7283
reply:
7384
channel:
7485
$ref: '#/channels/currencyExchange'
7586
messages:
7687
- $ref: '#/components/messages/subscriptionStatus'
88+
messages:
89+
- $ref: '#/components/messages/unsubscribe'
7790

7891

7992
components:
8093
messages:
94+
dummyCurrencyInfo:
95+
summary: Dummy message with no real life details
96+
description: It is here in this example to showcase that there is an additional message that normally is of a complex structure. It represents actually currency exchange value to show a reply to operation receiveSubscribeRequest with more than one possible message.
97+
payload:
98+
type: object
99+
properties:
100+
event:
101+
type: string
102+
const: currencyInfo
103+
reqid:
104+
$ref: '#/components/schemas/reqid'
105+
data:
106+
type: object
107+
required:
108+
- event
109+
correlationId:
110+
location: '$message.payload#/reqid'
111+
81112
ping:
82113
summary: Ping server to determine whether connection is alive
83114
description: Client can ping server to determine whether connection is alive, server responds with pong. This is an application level ping as opposed to default ping in websockets standard which is server initiated
84115
payload:
85116
$ref: '#/components/schemas/ping'
86117
correlationId:
87-
location: $message.payload#/reqid
118+
location: '$message.payload#/reqid'
88119

89120
pong:
90121
summary: Pong is a response to ping message
91122
description: Server pong response to a ping to determine whether connection is alive. This is an application level pong as opposed to default pong in websockets standard which is sent by client in response to a ping
92123
payload:
93124
$ref: '#/components/schemas/pong'
94125
correlationId:
95-
location: $message.payload#/reqid
126+
location: '$message.payload#/reqid'
96127

97128
subscribe:
98129
description: Subscribe to a topic on a single or multiple currency pairs.
99130
payload:
100131
$ref: '#/components/schemas/subscribe'
101132
correlationId:
102-
location: $message.payload#/reqid
133+
location: '$message.payload#/reqid'
103134
unsubscribe:
104135
description: Unsubscribe, can specify a channelID or multiple currency pairs.
105136
payload:
106137
$ref: '#/components/schemas/unsubscribe'
107138
correlationId:
108-
location: $message.payload#/reqid
139+
location: '$message.payload#/reqid'
109140
subscriptionStatus:
110141
description: Subscription status response to subscribe, unsubscribe or exchange initiated unsubscribe.
111142
payload:

examples/kraken-websocket-request-reply-multiple-channels.yml renamed to examples/kraken-websocket-request-reply-multiple-channels-asyncapi.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,57 +42,79 @@ channels:
4242
systemStatus:
4343
$ref: '#/components/messages/systemStatus'
4444

45-
subscriptionStatus:
45+
currencyInfo:
4646
address: /
4747
messages:
4848
subscriptionStatus:
4949
$ref: '#/components/messages/subscriptionStatus'
50+
dummyCurrencyInfo:
51+
$ref: '#/components/messages/dummyCurrencyInfo'
52+
5053
subscribe:
5154
address: /
5255
messages:
5356
subscribe:
5457
$ref: '#/components/messages/subscribe'
58+
5559
unsubscribe:
5660
address: /
5761
messages:
5862
unsubscribe:
5963
$ref: '#/components/messages/unsubscribe'
60-
6164

6265
operations:
63-
pingPong:
64-
action: send
66+
receivePing:
67+
action: receive
6568
channel:
6669
$ref: '#/channels/ping'
6770
reply:
6871
channel:
6972
$ref: '#/channels/pong'
7073
heartbeat:
71-
action: receive
74+
action: send
7275
channel:
7376
$ref: '#/channels/heartbeat'
7477
systemStatus:
75-
action: receive
78+
action: send
7679
channel:
7780
$ref: '#/channels/systemStatus'
7881
subscribe:
79-
action: send
82+
action: receive
8083
channel:
8184
$ref: '#/channels/subscribe'
8285
reply:
8386
channel:
84-
$ref: '#/channels/subscriptionStatus'
87+
$ref: '#/channels/currencyInfo'
8588
unsubscribe:
86-
action: send
89+
action: receive
8790
channel:
8891
$ref: '#/channels/unsubscribe'
8992
reply:
9093
channel:
91-
$ref: '#/channels/subscriptionStatus'
94+
$ref: '#/channels/currencyInfo'
95+
messages:
96+
- $ref: '#/components/messages/subscriptionStatus'
9297

9398

9499
components:
95100
messages:
101+
dummyCurrencyInfo:
102+
summary: Dummy message with no real life details
103+
description: It is here in this example to showcase that there is an additional message that normally is of a complex structure. It represents actually currency exchange value to show a reply to operation receiveSubscribeRequest with more than one possible message.
104+
payload:
105+
type: object
106+
properties:
107+
event:
108+
type: string
109+
const: currencyInfo
110+
reqid:
111+
$ref: '#/components/schemas/reqid'
112+
data:
113+
type: object
114+
required:
115+
- event
116+
correlationId:
117+
location: '$message.payload#/reqid'
96118
ping:
97119
summary: Ping server to determine whether connection is alive
98120
description: Client can ping server to determine whether connection is alive, server responds with pong. This is an application level ping as opposed to default ping in websockets standard which is server initiated

0 commit comments

Comments
 (0)