Skip to content

Commit

Permalink
feat: update bundler to support spec v3 (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
Souvikns authored Dec 7, 2023
1 parent 8dd1ad4 commit 06545b9
Show file tree
Hide file tree
Showing 13 changed files with 9,793 additions and 19,024 deletions.
45 changes: 45 additions & 0 deletions example/v3/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
asyncapi: 3.0.0
info:
title: Account Service
version: 1.0.0
description: This service is in charge of processing user signupsA
channels:
userSignedup:
address: user/signedup
messages:
userSignedUpMessage:
$ref: '#/components/messages/UserSignedUp'
test:
address: /test
messages:
testMessage:
$ref: '#/components/messages/TestMessage'
operations:
UserSignedUp:
action: send
channel:
$ref: '#/channels/userSignedup'
messages:
- $ref: '#/components/messages/UserSignedUp'
TestOpp:
action: send
channel:
$ref: '#/channels/test'
messages:
- $ref: '#/components/messages/TestMessage'
components:
messages:
TestMessage:
payload:
type: string
UserSignedUp:
payload:
type: object
properties:
displayName:
type: string
description: Name of the user
email:
type: string
format: email
description: Email of the user
65 changes: 65 additions & 0 deletions example/v3/audio.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
asyncapi: 3.0.0
id: 'urn:zbos-mqtt-api'
info:
title: Audio
version: 2.6.3
description: API for communication with ZBOS by Zora Robotics.
contact:
email: [email protected]
defaultContentType: application/json
channels:
zbos/audio/player/start:
address: zbos/audio/player/start
messages:
publish.message:
payload:
type: object
properties:
requestId:
type: string
url:
type: string
loop:
type: boolean
name: AudioOptions
examples:
- payload:
requestId: '1'
url: Url
loop: true
zbos/audio/player/stop:
address: zbos/audio/player/stop
messages:
publish.message:
$ref: '#/components/messages/emptyMessage'
operations:
zbos/audio/player/start.publish:
action: receive
channel:
$ref: '#/channels/zbos~1audio~1player~1start'
summary: Play media
description: |
Play specific media from audio options
tags:
- name: Audio
description: All audio related topics.
messages:
- $ref: '#/channels/zbos~1audio~1player~1start/messages/publish.message'
zbos/audio/player/stop.publish:
action: receive
channel:
$ref: '#/channels/zbos~1audio~1player~1stop'
summary: Stop media
description: ''
tags:
- name: Audio
description: All audio related topics.
messages:
- $ref: '#/channels/zbos~1audio~1player~1stop/messages/publish.message'
components:
messages:
emptyMessage:
payload:
type: object
name: EmptyMessage
summary: Empty message
23 changes: 23 additions & 0 deletions example/v3/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const bundle = require('@asyncapi/bundler')
const {readFileSync, writeFileSync} = require('fs')

async function main() {
await singleFile()
await multiFile()
}


async function singleFile(){
const document = await bundle([readFileSync('./main.yaml', 'utf-8')] )

writeFileSync('asyncapi.yaml', document.yml())

}

async function multiFile(){
const document = await bundle(['./camera.yml', './audio.yml'].map( f => readFileSync(f, 'utf-8')))
writeFileSync('spec.yaml', document.yml())
}


main().catch(e => console.error(e))
59 changes: 59 additions & 0 deletions example/v3/camera.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
asyncapi: 3.0.0
id: 'urn:zbos-mqtt-api'
info:
title: Camera
version: 2.6.3
description: API for communication with ZBOS by Zora Robotics.
contact:
email: [email protected]
defaultContentType: application/json
channels:
zbos/camera/picture/event:
address: zbos/camera/picture/event
messages:
subscribe.message:
payload:
type: string
name: String
zbos/camera/picture/get:
address: zbos/camera/picture/get
messages:
publish.message:
$ref: '#/components/messages/keyMessage'
operations:
zbos/camera/picture/event.subscribe:
action: send
channel:
$ref: '#/channels/zbos~1camera~1picture~1event'
summary: 'event: Get picture'
description: ''
tags:
- name: Camera
description: All camera related topics.
messages:
- $ref: '#/channels/zbos~1camera~1picture~1event/messages/subscribe.message'
zbos/camera/picture/get.publish:
action: receive
channel:
$ref: '#/channels/zbos~1camera~1picture~1get'
summary: Get picture
description: ''
tags:
- name: Camera
description: All camera related topics.
messages:
- $ref: '#/channels/zbos~1camera~1picture~1get/messages/publish.message'
components:
messages:
keyMessage:
payload:
type: object
properties:
key:
type: string
description: Required random key
name: KeyResult
summary: Random key
examples:
- payload:
key: ABCxyz
34 changes: 34 additions & 0 deletions example/v3/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
asyncapi: 3.0.0
info:
title: Account Service
version: 1.0.0
description: This service is in charge of processing user signupsA
channels:
userSignedup:
address: 'user/signedup'
messages:
userSignedUpMessage:
$ref: './messages.yaml#/messages/UserSignedUp'
test:
address: '/test'
messages:
testMessage:
$ref: '#/components/messages/TestMessage'
operations:
UserSignedUp:
action: send
channel:
$ref: '#/channels/userSignedup'
messages:
- $ref: './messages.yaml#/messages/UserSignedUp'
TestOpp:
action: send
channel:
$ref: '#/channels/test'
messages:
- $ref: '#/components/messages/TestMessage'
components:
messages:
TestMessage:
payload:
type: string
17 changes: 17 additions & 0 deletions example/v3/messages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
messages:
UserSignedUp:
payload:
type: object
properties:
displayName:
type: string
description: Name of the user
email:
type: string
format: email
description: Email of the user
UserLoggedIn:
payload:
type: object
properties:
id: string
56 changes: 56 additions & 0 deletions example/v3/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions example/v3/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "v3",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@asyncapi/bundler": "../../"
}
}
Loading

0 comments on commit 06545b9

Please sign in to comment.