Skip to content

Commit 06545b9

Browse files
authored
feat: update bundler to support spec v3 (#140)
1 parent 8dd1ad4 commit 06545b9

File tree

13 files changed

+9793
-19024
lines changed

13 files changed

+9793
-19024
lines changed

example/v3/asyncapi.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
asyncapi: 3.0.0
2+
info:
3+
title: Account Service
4+
version: 1.0.0
5+
description: This service is in charge of processing user signupsA
6+
channels:
7+
userSignedup:
8+
address: user/signedup
9+
messages:
10+
userSignedUpMessage:
11+
$ref: '#/components/messages/UserSignedUp'
12+
test:
13+
address: /test
14+
messages:
15+
testMessage:
16+
$ref: '#/components/messages/TestMessage'
17+
operations:
18+
UserSignedUp:
19+
action: send
20+
channel:
21+
$ref: '#/channels/userSignedup'
22+
messages:
23+
- $ref: '#/components/messages/UserSignedUp'
24+
TestOpp:
25+
action: send
26+
channel:
27+
$ref: '#/channels/test'
28+
messages:
29+
- $ref: '#/components/messages/TestMessage'
30+
components:
31+
messages:
32+
TestMessage:
33+
payload:
34+
type: string
35+
UserSignedUp:
36+
payload:
37+
type: object
38+
properties:
39+
displayName:
40+
type: string
41+
description: Name of the user
42+
email:
43+
type: string
44+
format: email
45+
description: Email of the user

example/v3/audio.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
asyncapi: 3.0.0
2+
id: 'urn:zbos-mqtt-api'
3+
info:
4+
title: Audio
5+
version: 2.6.3
6+
description: API for communication with ZBOS by Zora Robotics.
7+
contact:
8+
email: info@zorarobotics.be
9+
defaultContentType: application/json
10+
channels:
11+
zbos/audio/player/start:
12+
address: zbos/audio/player/start
13+
messages:
14+
publish.message:
15+
payload:
16+
type: object
17+
properties:
18+
requestId:
19+
type: string
20+
url:
21+
type: string
22+
loop:
23+
type: boolean
24+
name: AudioOptions
25+
examples:
26+
- payload:
27+
requestId: '1'
28+
url: Url
29+
loop: true
30+
zbos/audio/player/stop:
31+
address: zbos/audio/player/stop
32+
messages:
33+
publish.message:
34+
$ref: '#/components/messages/emptyMessage'
35+
operations:
36+
zbos/audio/player/start.publish:
37+
action: receive
38+
channel:
39+
$ref: '#/channels/zbos~1audio~1player~1start'
40+
summary: Play media
41+
description: |
42+
Play specific media from audio options
43+
tags:
44+
- name: Audio
45+
description: All audio related topics.
46+
messages:
47+
- $ref: '#/channels/zbos~1audio~1player~1start/messages/publish.message'
48+
zbos/audio/player/stop.publish:
49+
action: receive
50+
channel:
51+
$ref: '#/channels/zbos~1audio~1player~1stop'
52+
summary: Stop media
53+
description: ''
54+
tags:
55+
- name: Audio
56+
description: All audio related topics.
57+
messages:
58+
- $ref: '#/channels/zbos~1audio~1player~1stop/messages/publish.message'
59+
components:
60+
messages:
61+
emptyMessage:
62+
payload:
63+
type: object
64+
name: EmptyMessage
65+
summary: Empty message

example/v3/bundle.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const bundle = require('@asyncapi/bundler')
2+
const {readFileSync, writeFileSync} = require('fs')
3+
4+
async function main() {
5+
await singleFile()
6+
await multiFile()
7+
}
8+
9+
10+
async function singleFile(){
11+
const document = await bundle([readFileSync('./main.yaml', 'utf-8')] )
12+
13+
writeFileSync('asyncapi.yaml', document.yml())
14+
15+
}
16+
17+
async function multiFile(){
18+
const document = await bundle(['./camera.yml', './audio.yml'].map( f => readFileSync(f, 'utf-8')))
19+
writeFileSync('spec.yaml', document.yml())
20+
}
21+
22+
23+
main().catch(e => console.error(e))

example/v3/camera.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
asyncapi: 3.0.0
2+
id: 'urn:zbos-mqtt-api'
3+
info:
4+
title: Camera
5+
version: 2.6.3
6+
description: API for communication with ZBOS by Zora Robotics.
7+
contact:
8+
email: info@zorarobotics.be
9+
defaultContentType: application/json
10+
channels:
11+
zbos/camera/picture/event:
12+
address: zbos/camera/picture/event
13+
messages:
14+
subscribe.message:
15+
payload:
16+
type: string
17+
name: String
18+
zbos/camera/picture/get:
19+
address: zbos/camera/picture/get
20+
messages:
21+
publish.message:
22+
$ref: '#/components/messages/keyMessage'
23+
operations:
24+
zbos/camera/picture/event.subscribe:
25+
action: send
26+
channel:
27+
$ref: '#/channels/zbos~1camera~1picture~1event'
28+
summary: 'event: Get picture'
29+
description: ''
30+
tags:
31+
- name: Camera
32+
description: All camera related topics.
33+
messages:
34+
- $ref: '#/channels/zbos~1camera~1picture~1event/messages/subscribe.message'
35+
zbos/camera/picture/get.publish:
36+
action: receive
37+
channel:
38+
$ref: '#/channels/zbos~1camera~1picture~1get'
39+
summary: Get picture
40+
description: ''
41+
tags:
42+
- name: Camera
43+
description: All camera related topics.
44+
messages:
45+
- $ref: '#/channels/zbos~1camera~1picture~1get/messages/publish.message'
46+
components:
47+
messages:
48+
keyMessage:
49+
payload:
50+
type: object
51+
properties:
52+
key:
53+
type: string
54+
description: Required random key
55+
name: KeyResult
56+
summary: Random key
57+
examples:
58+
- payload:
59+
key: ABCxyz

example/v3/main.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
asyncapi: 3.0.0
2+
info:
3+
title: Account Service
4+
version: 1.0.0
5+
description: This service is in charge of processing user signupsA
6+
channels:
7+
userSignedup:
8+
address: 'user/signedup'
9+
messages:
10+
userSignedUpMessage:
11+
$ref: './messages.yaml#/messages/UserSignedUp'
12+
test:
13+
address: '/test'
14+
messages:
15+
testMessage:
16+
$ref: '#/components/messages/TestMessage'
17+
operations:
18+
UserSignedUp:
19+
action: send
20+
channel:
21+
$ref: '#/channels/userSignedup'
22+
messages:
23+
- $ref: './messages.yaml#/messages/UserSignedUp'
24+
TestOpp:
25+
action: send
26+
channel:
27+
$ref: '#/channels/test'
28+
messages:
29+
- $ref: '#/components/messages/TestMessage'
30+
components:
31+
messages:
32+
TestMessage:
33+
payload:
34+
type: string

example/v3/messages.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
messages:
2+
UserSignedUp:
3+
payload:
4+
type: object
5+
properties:
6+
displayName:
7+
type: string
8+
description: Name of the user
9+
email:
10+
type: string
11+
format: email
12+
description: Email of the user
13+
UserLoggedIn:
14+
payload:
15+
type: object
16+
properties:
17+
id: string

example/v3/package-lock.json

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/v3/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "v3",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"@asyncapi/bundler": "../../"
14+
}
15+
}

0 commit comments

Comments
 (0)