@asyncapi/converter 0.6.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/add-good-first-issue-labels.yml +68 -0
- package/.github/workflows/automerge-for-humans-merging.yml +1 -1
- package/.github/workflows/automerge.yml +9 -18
- package/.github/workflows/autoupdate.yml +9 -5
- package/.github/workflows/bump.yml +3 -2
- package/.github/workflows/help-command.yml +19 -4
- package/.github/workflows/if-go-pr-testing.yml +17 -7
- package/.github/workflows/if-nodejs-pr-testing.yml +10 -4
- package/.github/workflows/if-nodejs-release.yml +8 -3
- package/.github/workflows/notify-tsc-members-mention.yml +142 -0
- package/cli.js +10 -3
- package/lib/helpers.js +20 -2
- package/lib/index.js +18 -8
- package/package.json +1 -1
- package/test/index.js +58 -1
- package/test/input/2.0.0/streetlights.json +172 -0
- package/test/input/2.0.0/streetlights.yml +0 -1
- package/test/input/2.0.0-rc2/streetlights.yml +0 -1
- package/test/input/2.1.0/streetlights.yml +0 -1
- package/test/input/2.2.0/streetlights.yml +112 -0
- package/test/output/2.0.0/streetlights.yml +0 -1
- package/test/output/2.0.0-rc2/streetlights.yml +0 -1
- package/test/output/2.1.0/streetlights.json +172 -0
- package/test/output/2.1.0/streetlights.yml +0 -1
- package/test/output/2.2.0/streetlights.yml +0 -1
- package/test/output/2.3.0/streetlights.yml +112 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#This workflow is centrally managed in https://github.com/asyncapi/.github/
|
|
2
|
+
#Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo
|
|
3
|
+
|
|
4
|
+
#Purpose of this workflow is to enable anyone to label issue with 'Good First Issue' and 'area/*' with a single command.
|
|
5
|
+
name: Add 'Good First Issue' and 'area/*' labels # if proper comment added
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
issue_comment:
|
|
9
|
+
types:
|
|
10
|
+
- created
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
add-labels:
|
|
14
|
+
if: ${{!github.event.issue.pull_request && github.event.issue.state != 'closed' && github.actor != 'asyncapi-bot'}}
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- name: Add label
|
|
18
|
+
if: contains(github.event.comment.body, '/good-first-issue') || contains(github.event.comment.body, '/gfi' )
|
|
19
|
+
uses: actions/github-script@v5
|
|
20
|
+
with:
|
|
21
|
+
github-token: ${{ secrets.GH_TOKEN }}
|
|
22
|
+
script: |
|
|
23
|
+
const areas = ['javascript', 'typescript', 'java' , 'go', 'docs', 'ci-cd', 'design'];
|
|
24
|
+
const values = context.payload.comment.body.split(" ");
|
|
25
|
+
switch(values[1]){
|
|
26
|
+
case 'ts':
|
|
27
|
+
values[1] = 'typescript';
|
|
28
|
+
break;
|
|
29
|
+
case 'js':
|
|
30
|
+
values[1] = 'javascript';
|
|
31
|
+
case 'markdown':
|
|
32
|
+
values[1] = 'docs';
|
|
33
|
+
}
|
|
34
|
+
if(values.length != 2 || !areas.includes(values[1])){
|
|
35
|
+
const message = `Hey @${context.payload.sender.login}, your message doesn't follow the requirements, you can try \`/help\`.`
|
|
36
|
+
|
|
37
|
+
await github.rest.issues.createComment({
|
|
38
|
+
issue_number: context.issue.number,
|
|
39
|
+
owner: context.repo.owner,
|
|
40
|
+
repo: context.repo.repo,
|
|
41
|
+
body: message
|
|
42
|
+
})
|
|
43
|
+
} else {
|
|
44
|
+
|
|
45
|
+
//remove complexity and areas if there are any before adding new labels;
|
|
46
|
+
const currentLabels = (await github.rest.issues.listLabelsOnIssue({
|
|
47
|
+
issue_number: context.issue.number,
|
|
48
|
+
owner: context.repo.owner,
|
|
49
|
+
repo: context.repo.repo,
|
|
50
|
+
})).data.map(label => label.name);
|
|
51
|
+
|
|
52
|
+
const shouldBeRemoved = currentLabels.filter(label => (label.startsWith('area/') && !label.endsWith(values[1])));
|
|
53
|
+
shouldBeRemoved.forEach(label => {
|
|
54
|
+
github.rest.issues.deleteLabel({
|
|
55
|
+
owner: context.repo.owner,
|
|
56
|
+
repo: context.repo.repo,
|
|
57
|
+
name: label,
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
//add new labels
|
|
62
|
+
github.rest.issues.addLabels({
|
|
63
|
+
issue_number: context.issue.number,
|
|
64
|
+
owner: context.repo.owner,
|
|
65
|
+
repo: context.repo.repo,
|
|
66
|
+
labels: ['good first issue', `area/${values[1]}`]
|
|
67
|
+
});
|
|
68
|
+
}
|
|
@@ -27,6 +27,6 @@ jobs:
|
|
|
27
27
|
GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}"
|
|
28
28
|
MERGE_LABELS: "!do-not-merge,ready-to-merge"
|
|
29
29
|
MERGE_METHOD: "squash"
|
|
30
|
-
MERGE_COMMIT_MESSAGE: "
|
|
30
|
+
MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})"
|
|
31
31
|
MERGE_RETRIES: "20"
|
|
32
32
|
MERGE_RETRY_SLEEP: "30000"
|
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# This action is centrally managed in https://github.com/asyncapi/.github/
|
|
2
|
+
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo.
|
|
3
3
|
|
|
4
4
|
name: Automerge release bump PR
|
|
5
5
|
|
|
6
6
|
on:
|
|
7
7
|
pull_request_target:
|
|
8
8
|
types:
|
|
9
|
-
- labeled
|
|
10
|
-
- unlabeled
|
|
11
|
-
- synchronize
|
|
12
9
|
- opened
|
|
13
|
-
-
|
|
14
|
-
- ready_for_review
|
|
15
|
-
- reopened
|
|
16
|
-
- unlocked
|
|
17
|
-
pull_request_review:
|
|
18
|
-
types:
|
|
19
|
-
- submitted
|
|
10
|
+
- synchronize
|
|
20
11
|
|
|
21
12
|
jobs:
|
|
22
|
-
|
|
23
13
|
autoapprove:
|
|
24
|
-
if:
|
|
14
|
+
if: >
|
|
15
|
+
contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]"]'), github.event.pull_request.user.login) &&
|
|
16
|
+
contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]"]'), github.actor) &&
|
|
17
|
+
!contains(github.event.pull_request.labels.*.name, 'released')
|
|
25
18
|
runs-on: ubuntu-latest
|
|
26
19
|
steps:
|
|
27
20
|
- name: Autoapproving
|
|
@@ -39,12 +32,10 @@ jobs:
|
|
|
39
32
|
owner: context.repo.owner,
|
|
40
33
|
repo: context.repo.repo,
|
|
41
34
|
labels: ['autoapproved']
|
|
42
|
-
})
|
|
43
|
-
|
|
35
|
+
})
|
|
44
36
|
|
|
45
37
|
automerge:
|
|
46
38
|
needs: [autoapprove]
|
|
47
|
-
if: github.event.pull_request.user.login == 'asyncapi-bot' || github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'dependabot-preview[bot]'
|
|
48
39
|
runs-on: ubuntu-latest
|
|
49
40
|
steps:
|
|
50
41
|
- name: Automerging
|
|
@@ -54,6 +45,6 @@ jobs:
|
|
|
54
45
|
GITHUB_LOGIN: asyncapi-bot
|
|
55
46
|
MERGE_LABELS: ""
|
|
56
47
|
MERGE_METHOD: "squash"
|
|
57
|
-
MERGE_COMMIT_MESSAGE: "
|
|
48
|
+
MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})"
|
|
58
49
|
MERGE_RETRIES: "20"
|
|
59
50
|
MERGE_RETRY_SLEEP: "30000"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo
|
|
3
3
|
|
|
4
4
|
#This workflow is designed to work with:
|
|
5
|
-
# - autoapprove and automerge workflows for dependabot and asyncapibot.
|
|
5
|
+
# - autoapprove and automerge workflows for dependabot and asyncapibot.
|
|
6
6
|
# - special release branches that we from time to time create in upstream repos. If we open up PRs for them from the very beginning of the release, the release branch will constantly update with new things from the destination branch they are opened against
|
|
7
7
|
|
|
8
8
|
# It uses GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch.
|
|
@@ -11,17 +11,21 @@
|
|
|
11
11
|
name: autoupdate
|
|
12
12
|
|
|
13
13
|
on:
|
|
14
|
-
push:
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
push:
|
|
15
|
+
branches-ignore:
|
|
16
|
+
- 'version-bump/**'
|
|
17
|
+
- 'dependabot/**'
|
|
18
|
+
- 'bot/**'
|
|
19
|
+
- 'all-contributors/**'
|
|
17
20
|
|
|
21
|
+
jobs:
|
|
18
22
|
autoupdate:
|
|
19
23
|
runs-on: ubuntu-latest
|
|
20
24
|
steps:
|
|
21
25
|
- name: Autoupdating
|
|
22
26
|
uses: docker://chinthakagodawita/autoupdate-action:v1
|
|
23
27
|
env:
|
|
24
|
-
GITHUB_TOKEN: '${{ secrets.
|
|
28
|
+
GITHUB_TOKEN: '${{ secrets.GH_TOKEN }}'
|
|
25
29
|
PR_FILTER: "labelled"
|
|
26
30
|
PR_LABELS: "autoapproved"
|
|
27
31
|
PR_READY_STATE: "ready_for_review"
|
|
@@ -15,6 +15,7 @@ on:
|
|
|
15
15
|
|
|
16
16
|
jobs:
|
|
17
17
|
bump:
|
|
18
|
+
if: startsWith(github.event.commits[0].message, 'chore(release):')
|
|
18
19
|
runs-on: ubuntu-latest
|
|
19
20
|
steps:
|
|
20
21
|
- name: Checkout repo
|
|
@@ -22,9 +23,9 @@ jobs:
|
|
|
22
23
|
- name: Check if Node.js project and has package.json
|
|
23
24
|
id: packagejson
|
|
24
25
|
run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false"
|
|
25
|
-
- if: steps.packagejson.outputs.exists == 'true'
|
|
26
|
+
- if: steps.packagejson.outputs.exists == 'true'
|
|
26
27
|
name: Bumping latest version of this package in other repositories
|
|
27
|
-
uses: derberg/npm-dependency-manager-for-your-github-org@
|
|
28
|
+
uses: derberg/npm-dependency-manager-for-your-github-org@v4
|
|
28
29
|
with:
|
|
29
30
|
github_token: ${{ secrets.GH_TOKEN }}
|
|
30
31
|
committer_username: asyncapi-bot
|
|
@@ -9,12 +9,11 @@ on:
|
|
|
9
9
|
- created
|
|
10
10
|
|
|
11
11
|
jobs:
|
|
12
|
-
|
|
13
|
-
if: github.event.issue.pull_request
|
|
12
|
+
create_help_comment_pr:
|
|
13
|
+
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/help') && github.actor != 'asyncapi-bot' }}
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
steps:
|
|
16
16
|
- uses: actions-ecosystem/action-create-comment@v1
|
|
17
|
-
if: contains(github.event.comment.body, '/help')
|
|
18
17
|
with:
|
|
19
18
|
github_token: ${{ secrets.GH_TOKEN }}
|
|
20
19
|
body: |
|
|
@@ -25,4 +24,20 @@ jobs:
|
|
|
25
24
|
At the moment the following comments are supported in pull requests:
|
|
26
25
|
|
|
27
26
|
- `/ready-to-merge` or `/rtm` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added
|
|
28
|
-
- `/do-not-merge` or `/dnm` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
|
|
27
|
+
- `/do-not-merge` or `/dnm` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
|
|
28
|
+
create_help_comment_issue:
|
|
29
|
+
if: ${{ !github.event.issue.pull_request && contains(github.event.comment.body, '/help') && github.actor != 'asyncapi-bot' }}
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions-ecosystem/action-create-comment@v1
|
|
33
|
+
with:
|
|
34
|
+
github_token: ${{ secrets.GH_TOKEN }}
|
|
35
|
+
body: |
|
|
36
|
+
Hello, @${{ github.actor }}! 👋🏼
|
|
37
|
+
|
|
38
|
+
I'm Genie from the magic lamp. Looks like somebody needs a hand! 🆘
|
|
39
|
+
|
|
40
|
+
At the moment the following comments are supported in issues:
|
|
41
|
+
|
|
42
|
+
- `/good-first-issue {js | ts | java | go | docs | design | ci-cd} ` or `/gfi {js | ts | java | go | docs | design | ci-cd} ` - label an issue as a `good first issue`.
|
|
43
|
+
example: `/gfi js` or `/good-first-issue ci-cd`
|
|
@@ -6,16 +6,21 @@ name: PR testing - if Go project
|
|
|
6
6
|
on:
|
|
7
7
|
pull_request:
|
|
8
8
|
types: [opened, reopened, synchronize, ready_for_review]
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
jobs:
|
|
11
11
|
lint:
|
|
12
|
-
if: github.event.pull_request.draft == false
|
|
13
12
|
name: lint
|
|
14
13
|
runs-on: ubuntu-latest
|
|
15
14
|
steps:
|
|
16
|
-
-
|
|
15
|
+
- if: "github.event.pull_request.draft == false &&!((github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'ci: update global workflows')) || (github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'chore(release):')) || (github.actor == 'allcontributors' && startsWith(github.event.pull_request.title, 'docs: add')))"
|
|
16
|
+
id: should_run
|
|
17
|
+
name: Should Run
|
|
18
|
+
run: echo "::set-output name=shouldrun::true"
|
|
19
|
+
- if: steps.should_run.outputs.shouldrun == 'true'
|
|
20
|
+
name: Checkout repository
|
|
17
21
|
uses: actions/checkout@v2
|
|
18
|
-
-
|
|
22
|
+
- if: steps.should_run.outputs.shouldrun == 'true'
|
|
23
|
+
name: Check if Go project and has go.mod
|
|
19
24
|
id: gomod
|
|
20
25
|
run: test -e ./go.mod && echo "::set-output name=exists::true" || echo "::set-output name=exists::false"
|
|
21
26
|
shell: bash
|
|
@@ -31,16 +36,21 @@ jobs:
|
|
|
31
36
|
skip-go-installation: true # we wanna control the version of Go in use
|
|
32
37
|
|
|
33
38
|
test:
|
|
34
|
-
if: github.event.pull_request.draft == false
|
|
35
39
|
name: ${{ matrix.os }}
|
|
36
40
|
runs-on: ${{ matrix.os }}
|
|
37
41
|
strategy:
|
|
38
42
|
matrix:
|
|
39
43
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
40
44
|
steps:
|
|
41
|
-
-
|
|
45
|
+
- if: "github.event.pull_request.draft == false &&!((github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'ci: update global workflows')) || (github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'chore(release):')) || (github.actor == 'allcontributors' && startsWith(github.event.pull_request.title, 'docs: add')))"
|
|
46
|
+
id: should_run
|
|
47
|
+
name: Should Run
|
|
48
|
+
run: echo "::set-output name=shouldrun::true"
|
|
49
|
+
- if: steps.should_run.outputs.shouldrun == 'true'
|
|
50
|
+
name: Checkout repository
|
|
42
51
|
uses: actions/checkout@v2
|
|
43
|
-
-
|
|
52
|
+
- if: steps.should_run.outputs.shouldrun == 'true'
|
|
53
|
+
name: Check if Go project and has go.mod
|
|
44
54
|
id: gomod
|
|
45
55
|
run: test -e ./go.mod && echo "::set-output name=exists::true" || echo "::set-output name=exists::false"
|
|
46
56
|
shell: bash
|
|
@@ -9,20 +9,26 @@ on:
|
|
|
9
9
|
|
|
10
10
|
jobs:
|
|
11
11
|
test:
|
|
12
|
-
if: github.event.pull_request.draft == false
|
|
13
12
|
name: ${{ matrix.os }}
|
|
14
13
|
runs-on: ${{ matrix.os }}
|
|
15
14
|
strategy:
|
|
16
15
|
matrix:
|
|
17
16
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
18
17
|
steps:
|
|
19
|
-
-
|
|
18
|
+
- if: "github.event.pull_request.draft == false &&!((github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'ci: update global workflows')) || (github.actor == 'asyncapi-bot' && startsWith(github.event.pull_request.title, 'chore(release):')) || (github.actor == 'allcontributors' && startsWith(github.event.pull_request.title, 'docs: add')))"
|
|
19
|
+
id: should_run
|
|
20
|
+
name: Should Run
|
|
21
|
+
run: echo "::set-output name=shouldrun::true"
|
|
22
|
+
- if: steps.should_run.outputs.shouldrun == 'true'
|
|
23
|
+
name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows
|
|
20
24
|
run: |
|
|
21
25
|
git config --global core.autocrlf false
|
|
22
26
|
git config --global core.eol lf
|
|
23
|
-
-
|
|
27
|
+
- if: steps.should_run.outputs.shouldrun == 'true'
|
|
28
|
+
name: Checkout repository
|
|
24
29
|
uses: actions/checkout@v2
|
|
25
|
-
-
|
|
30
|
+
- if: steps.should_run.outputs.shouldrun == 'true'
|
|
31
|
+
name: Check if Node.js project and has package.json
|
|
26
32
|
id: packagejson
|
|
27
33
|
run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false"
|
|
28
34
|
shell: bash
|
|
@@ -10,7 +10,10 @@ on:
|
|
|
10
10
|
# below lines are not enough to have release supported for these branches
|
|
11
11
|
# make sure configuration of `semantic-release` package mentiones these branches
|
|
12
12
|
- next
|
|
13
|
-
-
|
|
13
|
+
- next-major
|
|
14
|
+
- beta
|
|
15
|
+
- alpha
|
|
16
|
+
- '**-release' # custom
|
|
14
17
|
|
|
15
18
|
jobs:
|
|
16
19
|
|
|
@@ -47,7 +50,7 @@ jobs:
|
|
|
47
50
|
|
|
48
51
|
release:
|
|
49
52
|
needs: test
|
|
50
|
-
name: Publish to NPM and
|
|
53
|
+
name: Publish to any of NPM, Github, and Docker Hub
|
|
51
54
|
runs-on: ubuntu-latest
|
|
52
55
|
steps:
|
|
53
56
|
- name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows
|
|
@@ -68,11 +71,13 @@ jobs:
|
|
|
68
71
|
name: Install dependencies
|
|
69
72
|
run: npm install
|
|
70
73
|
- if: steps.packagejson.outputs.exists == 'true'
|
|
71
|
-
name:
|
|
74
|
+
name: Publish to any of NPM, Github, and Docker Hub
|
|
72
75
|
id: release
|
|
73
76
|
env:
|
|
74
77
|
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
75
78
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
79
|
+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
80
|
+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
76
81
|
GIT_AUTHOR_NAME: asyncapi-bot
|
|
77
82
|
GIT_AUTHOR_EMAIL: info@asyncapi.io
|
|
78
83
|
GIT_COMMITTER_NAME: asyncapi-bot
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#This action is centrally managed in https://github.com/asyncapi/.github/
|
|
2
|
+
#Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo
|
|
3
|
+
|
|
4
|
+
#This action notifies community on slack whenever there is a new issue, PR or discussion started in given repository
|
|
5
|
+
name: Notify slack whenever TSC members are mentioned in GitHub
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
issue_comment:
|
|
9
|
+
types:
|
|
10
|
+
- created
|
|
11
|
+
- edited
|
|
12
|
+
|
|
13
|
+
discussion_comment:
|
|
14
|
+
types:
|
|
15
|
+
- created
|
|
16
|
+
- edited
|
|
17
|
+
|
|
18
|
+
issues:
|
|
19
|
+
types:
|
|
20
|
+
- opened
|
|
21
|
+
- reopened
|
|
22
|
+
|
|
23
|
+
pull_request_target:
|
|
24
|
+
types:
|
|
25
|
+
- opened
|
|
26
|
+
- reopened
|
|
27
|
+
- ready_for_review
|
|
28
|
+
|
|
29
|
+
discussion:
|
|
30
|
+
types:
|
|
31
|
+
- created
|
|
32
|
+
- edited
|
|
33
|
+
|
|
34
|
+
jobs:
|
|
35
|
+
|
|
36
|
+
issue:
|
|
37
|
+
if: github.event_name == 'issues' && contains(github.event.issue.body, '@asyncapi/tsc_members')
|
|
38
|
+
name: On every new issue
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
steps:
|
|
41
|
+
- name: Convert markdown to slack markdown
|
|
42
|
+
uses: LoveToKnow/slackify-markdown-action@v1.0.0
|
|
43
|
+
id: issuemarkdown
|
|
44
|
+
with:
|
|
45
|
+
text: "[${{github.event.issue.title}}](${{github.event.issue.html_url}}) \n ${{github.event.issue.body}}"
|
|
46
|
+
- name: Send info about issue
|
|
47
|
+
uses: rtCamp/action-slack-notify@v2
|
|
48
|
+
env:
|
|
49
|
+
SLACK_WEBHOOK: ${{secrets.SLACK_TSC_MEMBERS_NOTIFY}}
|
|
50
|
+
SLACK_TITLE: 🆘 New issue that requires TSC Members attention 🆘
|
|
51
|
+
SLACK_MESSAGE: ${{steps.issuemarkdown.outputs.text}}
|
|
52
|
+
MSG_MINIMAL: true
|
|
53
|
+
|
|
54
|
+
pull_request:
|
|
55
|
+
if: github.event_name == 'pull_request_target' && contains(github.event.pull_request.body, '@asyncapi/tsc_members')
|
|
56
|
+
name: On every new pull request
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
steps:
|
|
59
|
+
- name: Convert markdown to slack markdown
|
|
60
|
+
uses: LoveToKnow/slackify-markdown-action@v1.0.0
|
|
61
|
+
id: prmarkdown
|
|
62
|
+
with:
|
|
63
|
+
text: "[${{github.event.pull_request.title}}](${{github.event.pull_request.html_url}}) \n ${{github.event.pull_request.body}}"
|
|
64
|
+
- name: Send info about pull request
|
|
65
|
+
uses: rtCamp/action-slack-notify@v2
|
|
66
|
+
env:
|
|
67
|
+
SLACK_WEBHOOK: ${{secrets.SLACK_TSC_MEMBERS_NOTIFY}}
|
|
68
|
+
SLACK_TITLE: 🆘 New PR that requires TSC Members attention 🆘
|
|
69
|
+
SLACK_MESSAGE: ${{steps.prmarkdown.outputs.text}}
|
|
70
|
+
MSG_MINIMAL: true
|
|
71
|
+
|
|
72
|
+
discussion:
|
|
73
|
+
if: github.event_name == 'discussion' && contains(github.event.discussion.body, '@asyncapi/tsc_members')
|
|
74
|
+
name: On every new discussion
|
|
75
|
+
runs-on: ubuntu-latest
|
|
76
|
+
steps:
|
|
77
|
+
- name: Convert markdown to slack markdown
|
|
78
|
+
uses: LoveToKnow/slackify-markdown-action@v1.0.0
|
|
79
|
+
id: discussionmarkdown
|
|
80
|
+
with:
|
|
81
|
+
text: "[${{github.event.discussion.title}}](${{github.event.discussion.html_url}}) \n ${{github.event.discussion.body}}"
|
|
82
|
+
- name: Send info about pull request
|
|
83
|
+
uses: rtCamp/action-slack-notify@v2
|
|
84
|
+
env:
|
|
85
|
+
SLACK_WEBHOOK: ${{secrets.SLACK_TSC_MEMBERS_NOTIFY}}
|
|
86
|
+
SLACK_TITLE: 🆘 New discussion that requires TSC Members attention 🆘
|
|
87
|
+
SLACK_MESSAGE: ${{steps.discussionmarkdown.outputs.text}}
|
|
88
|
+
MSG_MINIMAL: true
|
|
89
|
+
|
|
90
|
+
issue_comment:
|
|
91
|
+
if: ${{ github.event_name == 'issue_comment' && !github.event.issue.pull_request && contains(github.event.comment.body, '@asyncapi/tsc_members') }}
|
|
92
|
+
name: On every new comment in issue
|
|
93
|
+
runs-on: ubuntu-latest
|
|
94
|
+
steps:
|
|
95
|
+
- name: Convert markdown to slack markdown
|
|
96
|
+
uses: LoveToKnow/slackify-markdown-action@v1.0.0
|
|
97
|
+
id: issuemarkdown
|
|
98
|
+
with:
|
|
99
|
+
text: "[${{github.event.issue.title}}](${{github.event.comment.html_url}}) \n ${{github.event.comment.body}}"
|
|
100
|
+
- name: Send info about issue comment
|
|
101
|
+
uses: rtCamp/action-slack-notify@v2
|
|
102
|
+
env:
|
|
103
|
+
SLACK_WEBHOOK: ${{secrets.SLACK_TSC_MEMBERS_NOTIFY}}
|
|
104
|
+
SLACK_TITLE: 🆘 New comment under existing issue that requires TSC Members attention 🆘
|
|
105
|
+
SLACK_MESSAGE: ${{steps.issuemarkdown.outputs.text}}
|
|
106
|
+
MSG_MINIMAL: true
|
|
107
|
+
|
|
108
|
+
pr_comment:
|
|
109
|
+
if: github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, '@asyncapi/tsc_members')
|
|
110
|
+
name: On every new comment in pr
|
|
111
|
+
runs-on: ubuntu-latest
|
|
112
|
+
steps:
|
|
113
|
+
- name: Convert markdown to slack markdown
|
|
114
|
+
uses: LoveToKnow/slackify-markdown-action@v1.0.0
|
|
115
|
+
id: prmarkdown
|
|
116
|
+
with:
|
|
117
|
+
text: "[${{github.event.issue.title}}](${{github.event.comment.html_url}}) \n ${{github.event.comment.body}}"
|
|
118
|
+
- name: Send info about PR comment
|
|
119
|
+
uses: rtCamp/action-slack-notify@v2
|
|
120
|
+
env:
|
|
121
|
+
SLACK_WEBHOOK: ${{secrets.SLACK_TSC_MEMBERS_NOTIFY}}
|
|
122
|
+
SLACK_TITLE: 🆘 New comment under existing PR that requires TSC Members attention 🆘
|
|
123
|
+
SLACK_MESSAGE: ${{steps.prmarkdown.outputs.text}}
|
|
124
|
+
MSG_MINIMAL: true
|
|
125
|
+
|
|
126
|
+
discussion_comment:
|
|
127
|
+
if: github.event_name == 'discussion_comment' && contains(github.event.comment.body, '@asyncapi/tsc_members')
|
|
128
|
+
name: On every new comment in discussion
|
|
129
|
+
runs-on: ubuntu-latest
|
|
130
|
+
steps:
|
|
131
|
+
- name: Convert markdown to slack markdown
|
|
132
|
+
uses: LoveToKnow/slackify-markdown-action@v1.0.0
|
|
133
|
+
id: discussionmarkdown
|
|
134
|
+
with:
|
|
135
|
+
text: "[${{github.event.discussion.title}}](${{github.event.comment.html_url}}) \n ${{github.event.comment.body}}"
|
|
136
|
+
- name: Send info about discussion comment
|
|
137
|
+
uses: rtCamp/action-slack-notify@v2
|
|
138
|
+
env:
|
|
139
|
+
SLACK_WEBHOOK: ${{secrets.SLACK_TSC_MEMBERS_NOTIFY}}
|
|
140
|
+
SLACK_TITLE: 🆘 New comment under existing discussion that requires TSC Members attention 🆘
|
|
141
|
+
SLACK_MESSAGE: ${{steps.discussionmarkdown.outputs.text}}
|
|
142
|
+
MSG_MINIMAL: true
|
package/cli.js
CHANGED
|
@@ -32,14 +32,21 @@ if (!asyncapiFile) {
|
|
|
32
32
|
program.help(); // This exits the process
|
|
33
33
|
}
|
|
34
34
|
if (!version) {
|
|
35
|
-
version = '2.
|
|
35
|
+
version = '2.3.0';
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
try {
|
|
39
39
|
const asyncapi = fs.readFileSync(asyncapiFile, 'utf-8');
|
|
40
|
-
|
|
40
|
+
let converted = converter.convert(asyncapi, version, {
|
|
41
41
|
id: program.id,
|
|
42
|
-
})
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// JSON case
|
|
45
|
+
if (typeof converted === 'object') {
|
|
46
|
+
converted = JSON.stringify(converted, undefined, 2);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
console.log(converted);
|
|
43
50
|
} catch (e) {
|
|
44
51
|
showErrorAndExit(e);
|
|
45
52
|
}
|
package/lib/helpers.js
CHANGED
|
@@ -3,16 +3,34 @@ const yaml = require('js-yaml');
|
|
|
3
3
|
const helpers = module.exports;
|
|
4
4
|
|
|
5
5
|
helpers.serialize = (text) => {
|
|
6
|
+
if (typeof text === 'object') {
|
|
7
|
+
return {
|
|
8
|
+
isYAML: false,
|
|
9
|
+
parsed: text,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
try {
|
|
14
|
+
const maybeJSON = JSON.parse(text);
|
|
15
|
+
if (typeof maybeJSON === 'object') {
|
|
16
|
+
return {
|
|
17
|
+
isYAML: false,
|
|
18
|
+
parsed: maybeJSON,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// if `maybeJSON` is object, then we have 100% sure that we operate on JSON,
|
|
23
|
+
// but if it's `string` then we have option that it can be YAML but it doesn't have to be
|
|
7
24
|
return {
|
|
8
25
|
isYAML: true,
|
|
9
26
|
parsed: yaml.safeLoad(text)
|
|
10
27
|
};
|
|
11
28
|
} catch (e) {
|
|
12
29
|
try {
|
|
30
|
+
// try to parse again YAML, because the text itself may not have a JSON representation and cannot be represented as a JSON object/string
|
|
13
31
|
return {
|
|
14
|
-
isYAML:
|
|
15
|
-
parsed:
|
|
32
|
+
isYAML: true,
|
|
33
|
+
parsed: yaml.safeLoad(text)
|
|
16
34
|
};
|
|
17
35
|
} catch (err) {
|
|
18
36
|
throw new Error('AsyncAPI document must be a valid JSON or YAML document.');
|
package/lib/index.js
CHANGED
|
@@ -22,6 +22,7 @@ const conversions = {
|
|
|
22
22
|
'2.0.0': from__2_0_0_rc2__to__2_0_0,
|
|
23
23
|
'2.1.0': from__2_0_0__to__2_1_0,
|
|
24
24
|
'2.2.0': from__2_1_0__to__2_2_0,
|
|
25
|
+
'2.3.0': from__2_2_0__to__2_3_0,
|
|
25
26
|
}
|
|
26
27
|
const conversionVersions = Object.keys(conversions);
|
|
27
28
|
|
|
@@ -181,6 +182,12 @@ function from__2_0_0_rc1__to__2_0_0_rc2(asyncapi2rc1, options) { // NOSONAR
|
|
|
181
182
|
});
|
|
182
183
|
}
|
|
183
184
|
|
|
185
|
+
if (result.components && result.components.parameters) {
|
|
186
|
+
_.each(result.components.parameters, (parameter) => {
|
|
187
|
+
if (parameter.name) delete parameter.name;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
184
191
|
if (!options.id) delete result.id;
|
|
185
192
|
return result;
|
|
186
193
|
}
|
|
@@ -192,14 +199,17 @@ function from__2_0_0_rc2__to__2_0_0(asyncapi2rc2, options) {
|
|
|
192
199
|
return result;
|
|
193
200
|
}
|
|
194
201
|
|
|
195
|
-
function from__2_0_0__to__2_1_0(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return result;
|
|
202
|
+
function from__2_0_0__to__2_1_0(asyncapi) {
|
|
203
|
+
asyncapi.asyncapi = '2.1.0';
|
|
204
|
+
return asyncapi;
|
|
199
205
|
}
|
|
200
206
|
|
|
201
|
-
function from__2_1_0__to__2_2_0(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return result;
|
|
207
|
+
function from__2_1_0__to__2_2_0(asyncapi) {
|
|
208
|
+
asyncapi.asyncapi = '2.2.0';
|
|
209
|
+
return asyncapi;
|
|
205
210
|
}
|
|
211
|
+
|
|
212
|
+
function from__2_2_0__to__2_3_0(asyncapi) {
|
|
213
|
+
asyncapi.asyncapi = '2.3.0';
|
|
214
|
+
return asyncapi;
|
|
215
|
+
}
|
package/package.json
CHANGED
package/test/index.js
CHANGED
|
@@ -2,6 +2,7 @@ const assert = require('assert');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const { convert } = require('../lib');
|
|
5
|
+
const { serialize } = require('../lib/helpers');
|
|
5
6
|
|
|
6
7
|
describe('#convert', () => {
|
|
7
8
|
it('should not convert to lowest version', () => {
|
|
@@ -179,6 +180,62 @@ describe('#convert', () => {
|
|
|
179
180
|
const result = convert(input, '2.2.0');
|
|
180
181
|
assertResults(output, result);
|
|
181
182
|
});
|
|
183
|
+
|
|
184
|
+
it('should convert from 2.1.0 to 2.3.0', () => {
|
|
185
|
+
const input = fs.readFileSync(path.resolve(__dirname, 'input', '2.1.0', 'streetlights.yml'), 'utf8');
|
|
186
|
+
const output = fs.readFileSync(path.resolve(__dirname, 'output', '2.3.0', 'streetlights.yml'), 'utf8');
|
|
187
|
+
const result = convert(input, '2.3.0');
|
|
188
|
+
assertResults(output, result);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('should convert from 2.2.0 to 2.3.0', () => {
|
|
192
|
+
const input = fs.readFileSync(path.resolve(__dirname, 'input', '2.2.0', 'streetlights.yml'), 'utf8');
|
|
193
|
+
const output = fs.readFileSync(path.resolve(__dirname, 'output', '2.3.0', 'streetlights.yml'), 'utf8');
|
|
194
|
+
const result = convert(input, '2.3.0');
|
|
195
|
+
assertResults(output, result);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('should convert from 2.0.0 to 2.1.0 (JSON case)', () => {
|
|
199
|
+
const input = fs.readFileSync(path.resolve(__dirname, 'input', '2.0.0', 'streetlights.json'), 'utf8');
|
|
200
|
+
let output = fs.readFileSync(path.resolve(__dirname, 'output', '2.1.0', 'streetlights.json'), 'utf8');
|
|
201
|
+
let result = convert(input, '2.1.0');
|
|
202
|
+
|
|
203
|
+
output = JSON.stringify(JSON.parse(output));
|
|
204
|
+
result = JSON.stringify(JSON.parse(JSON.stringify(result)));
|
|
205
|
+
assert.strictEqual(output, result);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
describe('#serialize', () => {
|
|
210
|
+
it('should serialize JSON', () => {
|
|
211
|
+
const input = '{"foo": "bar"}';
|
|
212
|
+
const output = serialize(input);
|
|
213
|
+
assert.strictEqual(output.isYAML, false);
|
|
214
|
+
assert.deepEqual(output.parsed, {foo: "bar"});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('should serialize YAML', () => {
|
|
218
|
+
const input = 'foo: bar';
|
|
219
|
+
const output = serialize(input);
|
|
220
|
+
assert.strictEqual(output.isYAML, true);
|
|
221
|
+
assert.deepEqual(output.parsed, {foo: "bar"});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('should serialize YAML (with JSON syntax)', () => {
|
|
225
|
+
const input = '{foo: bar}';
|
|
226
|
+
const output = serialize(input);
|
|
227
|
+
assert.strictEqual(output.isYAML, true);
|
|
228
|
+
assert.deepEqual(output.parsed, {foo: "bar"});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('should throw error', () => {
|
|
232
|
+
const input = '%{foo: bar}';
|
|
233
|
+
try {
|
|
234
|
+
serialize(input);
|
|
235
|
+
} catch(e) {
|
|
236
|
+
assert.strictEqual(e.message, 'AsyncAPI document must be a valid JSON or YAML document.');
|
|
237
|
+
}
|
|
238
|
+
});
|
|
182
239
|
});
|
|
183
240
|
|
|
184
241
|
/*
|
|
@@ -191,4 +248,4 @@ function removeLineBreaks(str) {
|
|
|
191
248
|
|
|
192
249
|
function assertResults(output, result){
|
|
193
250
|
assert.strictEqual(removeLineBreaks(output), removeLineBreaks(result));
|
|
194
|
-
}
|
|
251
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{
|
|
2
|
+
"asyncapi": "2.0.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Streetlights API",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "The Smartylighting Streetlights API allows you to remotely manage the city lights.\n\n### Check out its awesome features:\n\n* Turn a specific streetlight on/off 🌃\n* Dim a specific streetlight 😎\n* Receive real-time information about environmental lighting conditions 📈\n",
|
|
7
|
+
"license": {
|
|
8
|
+
"name": "Apache 2.0",
|
|
9
|
+
"url": "https://www.apache.org/licenses/LICENSE-2.0"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"servers": {
|
|
13
|
+
"default": {
|
|
14
|
+
"url": "api.streetlights.smartylighting.com:{port}",
|
|
15
|
+
"description": "Test broker",
|
|
16
|
+
"variables": {
|
|
17
|
+
"port": {
|
|
18
|
+
"description": "Secure connection (TLS) is available through port 8883.",
|
|
19
|
+
"default": "1883",
|
|
20
|
+
"enum": [
|
|
21
|
+
"1883",
|
|
22
|
+
"8883"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"protocol": "mqtt",
|
|
27
|
+
"security": [
|
|
28
|
+
{
|
|
29
|
+
"apiKey": []
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"components": {
|
|
35
|
+
"messages": {
|
|
36
|
+
"lightMeasured": {
|
|
37
|
+
"summary": "Inform about environmental lighting conditions for a particular streetlight.",
|
|
38
|
+
"payload": {
|
|
39
|
+
"$ref": "#/components/schemas/lightMeasuredPayload"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"turnOnOff": {
|
|
43
|
+
"summary": "Command a particular streetlight to turn the lights on or off.",
|
|
44
|
+
"payload": {
|
|
45
|
+
"$ref": "#/components/schemas/turnOnOffPayload"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"dimLight": {
|
|
49
|
+
"summary": "Command a particular streetlight to dim the lights.",
|
|
50
|
+
"payload": {
|
|
51
|
+
"$ref": "#/components/schemas/dimLightPayload"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"schemas": {
|
|
56
|
+
"lightMeasuredPayload": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"properties": {
|
|
59
|
+
"lumens": {
|
|
60
|
+
"type": "integer",
|
|
61
|
+
"minimum": 0,
|
|
62
|
+
"description": "Light intensity measured in lumens."
|
|
63
|
+
},
|
|
64
|
+
"sentAt": {
|
|
65
|
+
"$ref": "#/components/schemas/sentAt"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"turnOnOffPayload": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"properties": {
|
|
72
|
+
"command": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"enum": [
|
|
75
|
+
"on",
|
|
76
|
+
"off"
|
|
77
|
+
],
|
|
78
|
+
"description": "Whether to turn on or off the light."
|
|
79
|
+
},
|
|
80
|
+
"sentAt": {
|
|
81
|
+
"$ref": "#/components/schemas/sentAt"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"dimLightPayload": {
|
|
86
|
+
"type": "object",
|
|
87
|
+
"properties": {
|
|
88
|
+
"percentage": {
|
|
89
|
+
"type": "integer",
|
|
90
|
+
"description": "Percentage to which the light should be dimmed to.",
|
|
91
|
+
"minimum": 0,
|
|
92
|
+
"maximum": 100
|
|
93
|
+
},
|
|
94
|
+
"sentAt": {
|
|
95
|
+
"$ref": "#/components/schemas/sentAt"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"sentAt": {
|
|
100
|
+
"type": "string",
|
|
101
|
+
"format": "date-time",
|
|
102
|
+
"description": "Date and time when the message was sent."
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"securitySchemes": {
|
|
106
|
+
"apiKey": {
|
|
107
|
+
"type": "apiKey",
|
|
108
|
+
"in": "user",
|
|
109
|
+
"description": "Provide your API key as the user and leave the password empty."
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"parameters": {
|
|
113
|
+
"streetlightId": {
|
|
114
|
+
"name": "streetlightId",
|
|
115
|
+
"description": "The ID of the streetlight.",
|
|
116
|
+
"schema": {
|
|
117
|
+
"type": "string"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"channels": {
|
|
123
|
+
"smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured": {
|
|
124
|
+
"parameters": {
|
|
125
|
+
"streetlightId": {
|
|
126
|
+
"$ref": "#/components/parameters/streetlightId"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"publish": {
|
|
130
|
+
"message": {
|
|
131
|
+
"$ref": "#/components/messages/lightMeasured"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"smartylighting/streetlights/1/0/action/{streetlightId}/turn/on": {
|
|
136
|
+
"parameters": {
|
|
137
|
+
"streetlightId": {
|
|
138
|
+
"$ref": "#/components/parameters/streetlightId"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"subscribe": {
|
|
142
|
+
"message": {
|
|
143
|
+
"$ref": "#/components/messages/turnOnOff"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"smartylighting/streetlights/1/0/action/{streetlightId}/turn/off": {
|
|
148
|
+
"parameters": {
|
|
149
|
+
"streetlightId": {
|
|
150
|
+
"$ref": "#/components/parameters/streetlightId"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"subscribe": {
|
|
154
|
+
"message": {
|
|
155
|
+
"$ref": "#/components/messages/turnOnOff"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
"smartylighting/streetlights/1/0/action/{streetlightId}/dim": {
|
|
160
|
+
"parameters": {
|
|
161
|
+
"streetlightId": {
|
|
162
|
+
"$ref": "#/components/parameters/streetlightId"
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"subscribe": {
|
|
166
|
+
"message": {
|
|
167
|
+
"$ref": "#/components/messages/dimLight"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
asyncapi: 2.2.0
|
|
2
|
+
info:
|
|
3
|
+
title: Streetlights API
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
description: "The Smartylighting Streetlights API allows you to remotely manage the city lights.\n\n### Check out its awesome features:\n\n* Turn a specific streetlight on/off \U0001F303\n* Dim a specific streetlight \U0001F60E\n* Receive real-time information about environmental lighting conditions \U0001F4C8\n"
|
|
6
|
+
license:
|
|
7
|
+
name: Apache 2.0
|
|
8
|
+
url: 'https://www.apache.org/licenses/LICENSE-2.0'
|
|
9
|
+
servers:
|
|
10
|
+
default:
|
|
11
|
+
url: 'api.streetlights.smartylighting.com:{port}'
|
|
12
|
+
description: Test broker
|
|
13
|
+
variables:
|
|
14
|
+
port:
|
|
15
|
+
description: Secure connection (TLS) is available through port 8883.
|
|
16
|
+
default: '1883'
|
|
17
|
+
enum:
|
|
18
|
+
- '1883'
|
|
19
|
+
- '8883'
|
|
20
|
+
protocol: mqtt
|
|
21
|
+
security:
|
|
22
|
+
- apiKey: []
|
|
23
|
+
components:
|
|
24
|
+
messages:
|
|
25
|
+
lightMeasured:
|
|
26
|
+
summary: >-
|
|
27
|
+
Inform about environmental lighting conditions for a particular
|
|
28
|
+
streetlight.
|
|
29
|
+
payload:
|
|
30
|
+
$ref: '#/components/schemas/lightMeasuredPayload'
|
|
31
|
+
turnOnOff:
|
|
32
|
+
summary: Command a particular streetlight to turn the lights on or off.
|
|
33
|
+
payload:
|
|
34
|
+
$ref: '#/components/schemas/turnOnOffPayload'
|
|
35
|
+
dimLight:
|
|
36
|
+
summary: Command a particular streetlight to dim the lights.
|
|
37
|
+
payload:
|
|
38
|
+
$ref: '#/components/schemas/dimLightPayload'
|
|
39
|
+
schemas:
|
|
40
|
+
lightMeasuredPayload:
|
|
41
|
+
type: object
|
|
42
|
+
properties:
|
|
43
|
+
lumens:
|
|
44
|
+
type: integer
|
|
45
|
+
minimum: 0
|
|
46
|
+
description: Light intensity measured in lumens.
|
|
47
|
+
sentAt:
|
|
48
|
+
$ref: '#/components/schemas/sentAt'
|
|
49
|
+
turnOnOffPayload:
|
|
50
|
+
type: object
|
|
51
|
+
properties:
|
|
52
|
+
command:
|
|
53
|
+
type: string
|
|
54
|
+
enum:
|
|
55
|
+
- 'on'
|
|
56
|
+
- 'off'
|
|
57
|
+
description: Whether to turn on or off the light.
|
|
58
|
+
sentAt:
|
|
59
|
+
$ref: '#/components/schemas/sentAt'
|
|
60
|
+
dimLightPayload:
|
|
61
|
+
type: object
|
|
62
|
+
properties:
|
|
63
|
+
percentage:
|
|
64
|
+
type: integer
|
|
65
|
+
description: Percentage to which the light should be dimmed to.
|
|
66
|
+
minimum: 0
|
|
67
|
+
maximum: 100
|
|
68
|
+
sentAt:
|
|
69
|
+
$ref: '#/components/schemas/sentAt'
|
|
70
|
+
sentAt:
|
|
71
|
+
type: string
|
|
72
|
+
format: date-time
|
|
73
|
+
description: Date and time when the message was sent.
|
|
74
|
+
securitySchemes:
|
|
75
|
+
apiKey:
|
|
76
|
+
type: apiKey
|
|
77
|
+
in: user
|
|
78
|
+
description: Provide your API key as the user and leave the password empty.
|
|
79
|
+
parameters:
|
|
80
|
+
streetlightId:
|
|
81
|
+
description: The ID of the streetlight.
|
|
82
|
+
schema:
|
|
83
|
+
type: string
|
|
84
|
+
channels:
|
|
85
|
+
'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured':
|
|
86
|
+
parameters:
|
|
87
|
+
streetlightId:
|
|
88
|
+
$ref: '#/components/parameters/streetlightId'
|
|
89
|
+
publish:
|
|
90
|
+
message:
|
|
91
|
+
$ref: '#/components/messages/lightMeasured'
|
|
92
|
+
'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on':
|
|
93
|
+
parameters:
|
|
94
|
+
streetlightId:
|
|
95
|
+
$ref: '#/components/parameters/streetlightId'
|
|
96
|
+
subscribe:
|
|
97
|
+
message:
|
|
98
|
+
$ref: '#/components/messages/turnOnOff'
|
|
99
|
+
'smartylighting/streetlights/1/0/action/{streetlightId}/turn/off':
|
|
100
|
+
parameters:
|
|
101
|
+
streetlightId:
|
|
102
|
+
$ref: '#/components/parameters/streetlightId'
|
|
103
|
+
subscribe:
|
|
104
|
+
message:
|
|
105
|
+
$ref: '#/components/messages/turnOnOff'
|
|
106
|
+
'smartylighting/streetlights/1/0/action/{streetlightId}/dim':
|
|
107
|
+
parameters:
|
|
108
|
+
streetlightId:
|
|
109
|
+
$ref: '#/components/parameters/streetlightId'
|
|
110
|
+
subscribe:
|
|
111
|
+
message:
|
|
112
|
+
$ref: '#/components/messages/dimLight'
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{
|
|
2
|
+
"asyncapi": "2.1.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Streetlights API",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "The Smartylighting Streetlights API allows you to remotely manage the city lights.\n\n### Check out its awesome features:\n\n* Turn a specific streetlight on/off 🌃\n* Dim a specific streetlight 😎\n* Receive real-time information about environmental lighting conditions 📈\n",
|
|
7
|
+
"license": {
|
|
8
|
+
"name": "Apache 2.0",
|
|
9
|
+
"url": "https://www.apache.org/licenses/LICENSE-2.0"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"servers": {
|
|
13
|
+
"default": {
|
|
14
|
+
"url": "api.streetlights.smartylighting.com:{port}",
|
|
15
|
+
"description": "Test broker",
|
|
16
|
+
"variables": {
|
|
17
|
+
"port": {
|
|
18
|
+
"description": "Secure connection (TLS) is available through port 8883.",
|
|
19
|
+
"default": "1883",
|
|
20
|
+
"enum": [
|
|
21
|
+
"1883",
|
|
22
|
+
"8883"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"protocol": "mqtt",
|
|
27
|
+
"security": [
|
|
28
|
+
{
|
|
29
|
+
"apiKey": []
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"components": {
|
|
35
|
+
"messages": {
|
|
36
|
+
"lightMeasured": {
|
|
37
|
+
"summary": "Inform about environmental lighting conditions for a particular streetlight.",
|
|
38
|
+
"payload": {
|
|
39
|
+
"$ref": "#/components/schemas/lightMeasuredPayload"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"turnOnOff": {
|
|
43
|
+
"summary": "Command a particular streetlight to turn the lights on or off.",
|
|
44
|
+
"payload": {
|
|
45
|
+
"$ref": "#/components/schemas/turnOnOffPayload"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"dimLight": {
|
|
49
|
+
"summary": "Command a particular streetlight to dim the lights.",
|
|
50
|
+
"payload": {
|
|
51
|
+
"$ref": "#/components/schemas/dimLightPayload"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"schemas": {
|
|
56
|
+
"lightMeasuredPayload": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"properties": {
|
|
59
|
+
"lumens": {
|
|
60
|
+
"type": "integer",
|
|
61
|
+
"minimum": 0,
|
|
62
|
+
"description": "Light intensity measured in lumens."
|
|
63
|
+
},
|
|
64
|
+
"sentAt": {
|
|
65
|
+
"$ref": "#/components/schemas/sentAt"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"turnOnOffPayload": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"properties": {
|
|
72
|
+
"command": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"enum": [
|
|
75
|
+
"on",
|
|
76
|
+
"off"
|
|
77
|
+
],
|
|
78
|
+
"description": "Whether to turn on or off the light."
|
|
79
|
+
},
|
|
80
|
+
"sentAt": {
|
|
81
|
+
"$ref": "#/components/schemas/sentAt"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"dimLightPayload": {
|
|
86
|
+
"type": "object",
|
|
87
|
+
"properties": {
|
|
88
|
+
"percentage": {
|
|
89
|
+
"type": "integer",
|
|
90
|
+
"description": "Percentage to which the light should be dimmed to.",
|
|
91
|
+
"minimum": 0,
|
|
92
|
+
"maximum": 100
|
|
93
|
+
},
|
|
94
|
+
"sentAt": {
|
|
95
|
+
"$ref": "#/components/schemas/sentAt"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"sentAt": {
|
|
100
|
+
"type": "string",
|
|
101
|
+
"format": "date-time",
|
|
102
|
+
"description": "Date and time when the message was sent."
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"securitySchemes": {
|
|
106
|
+
"apiKey": {
|
|
107
|
+
"type": "apiKey",
|
|
108
|
+
"in": "user",
|
|
109
|
+
"description": "Provide your API key as the user and leave the password empty."
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"parameters": {
|
|
113
|
+
"streetlightId": {
|
|
114
|
+
"name": "streetlightId",
|
|
115
|
+
"description": "The ID of the streetlight.",
|
|
116
|
+
"schema": {
|
|
117
|
+
"type": "string"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"channels": {
|
|
123
|
+
"smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured": {
|
|
124
|
+
"parameters": {
|
|
125
|
+
"streetlightId": {
|
|
126
|
+
"$ref": "#/components/parameters/streetlightId"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"publish": {
|
|
130
|
+
"message": {
|
|
131
|
+
"$ref": "#/components/messages/lightMeasured"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"smartylighting/streetlights/1/0/action/{streetlightId}/turn/on": {
|
|
136
|
+
"parameters": {
|
|
137
|
+
"streetlightId": {
|
|
138
|
+
"$ref": "#/components/parameters/streetlightId"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"subscribe": {
|
|
142
|
+
"message": {
|
|
143
|
+
"$ref": "#/components/messages/turnOnOff"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"smartylighting/streetlights/1/0/action/{streetlightId}/turn/off": {
|
|
148
|
+
"parameters": {
|
|
149
|
+
"streetlightId": {
|
|
150
|
+
"$ref": "#/components/parameters/streetlightId"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"subscribe": {
|
|
154
|
+
"message": {
|
|
155
|
+
"$ref": "#/components/messages/turnOnOff"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
"smartylighting/streetlights/1/0/action/{streetlightId}/dim": {
|
|
160
|
+
"parameters": {
|
|
161
|
+
"streetlightId": {
|
|
162
|
+
"$ref": "#/components/parameters/streetlightId"
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"subscribe": {
|
|
166
|
+
"message": {
|
|
167
|
+
"$ref": "#/components/messages/dimLight"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
asyncapi: 2.3.0
|
|
2
|
+
info:
|
|
3
|
+
title: Streetlights API
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
description: "The Smartylighting Streetlights API allows you to remotely manage the city lights.\n\n### Check out its awesome features:\n\n* Turn a specific streetlight on/off \U0001F303\n* Dim a specific streetlight \U0001F60E\n* Receive real-time information about environmental lighting conditions \U0001F4C8\n"
|
|
6
|
+
license:
|
|
7
|
+
name: Apache 2.0
|
|
8
|
+
url: 'https://www.apache.org/licenses/LICENSE-2.0'
|
|
9
|
+
servers:
|
|
10
|
+
default:
|
|
11
|
+
url: 'api.streetlights.smartylighting.com:{port}'
|
|
12
|
+
description: Test broker
|
|
13
|
+
variables:
|
|
14
|
+
port:
|
|
15
|
+
description: Secure connection (TLS) is available through port 8883.
|
|
16
|
+
default: '1883'
|
|
17
|
+
enum:
|
|
18
|
+
- '1883'
|
|
19
|
+
- '8883'
|
|
20
|
+
protocol: mqtt
|
|
21
|
+
security:
|
|
22
|
+
- apiKey: []
|
|
23
|
+
components:
|
|
24
|
+
messages:
|
|
25
|
+
lightMeasured:
|
|
26
|
+
summary: >-
|
|
27
|
+
Inform about environmental lighting conditions for a particular
|
|
28
|
+
streetlight.
|
|
29
|
+
payload:
|
|
30
|
+
$ref: '#/components/schemas/lightMeasuredPayload'
|
|
31
|
+
turnOnOff:
|
|
32
|
+
summary: Command a particular streetlight to turn the lights on or off.
|
|
33
|
+
payload:
|
|
34
|
+
$ref: '#/components/schemas/turnOnOffPayload'
|
|
35
|
+
dimLight:
|
|
36
|
+
summary: Command a particular streetlight to dim the lights.
|
|
37
|
+
payload:
|
|
38
|
+
$ref: '#/components/schemas/dimLightPayload'
|
|
39
|
+
schemas:
|
|
40
|
+
lightMeasuredPayload:
|
|
41
|
+
type: object
|
|
42
|
+
properties:
|
|
43
|
+
lumens:
|
|
44
|
+
type: integer
|
|
45
|
+
minimum: 0
|
|
46
|
+
description: Light intensity measured in lumens.
|
|
47
|
+
sentAt:
|
|
48
|
+
$ref: '#/components/schemas/sentAt'
|
|
49
|
+
turnOnOffPayload:
|
|
50
|
+
type: object
|
|
51
|
+
properties:
|
|
52
|
+
command:
|
|
53
|
+
type: string
|
|
54
|
+
enum:
|
|
55
|
+
- 'on'
|
|
56
|
+
- 'off'
|
|
57
|
+
description: Whether to turn on or off the light.
|
|
58
|
+
sentAt:
|
|
59
|
+
$ref: '#/components/schemas/sentAt'
|
|
60
|
+
dimLightPayload:
|
|
61
|
+
type: object
|
|
62
|
+
properties:
|
|
63
|
+
percentage:
|
|
64
|
+
type: integer
|
|
65
|
+
description: Percentage to which the light should be dimmed to.
|
|
66
|
+
minimum: 0
|
|
67
|
+
maximum: 100
|
|
68
|
+
sentAt:
|
|
69
|
+
$ref: '#/components/schemas/sentAt'
|
|
70
|
+
sentAt:
|
|
71
|
+
type: string
|
|
72
|
+
format: date-time
|
|
73
|
+
description: Date and time when the message was sent.
|
|
74
|
+
securitySchemes:
|
|
75
|
+
apiKey:
|
|
76
|
+
type: apiKey
|
|
77
|
+
in: user
|
|
78
|
+
description: Provide your API key as the user and leave the password empty.
|
|
79
|
+
parameters:
|
|
80
|
+
streetlightId:
|
|
81
|
+
description: The ID of the streetlight.
|
|
82
|
+
schema:
|
|
83
|
+
type: string
|
|
84
|
+
channels:
|
|
85
|
+
'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured':
|
|
86
|
+
parameters:
|
|
87
|
+
streetlightId:
|
|
88
|
+
$ref: '#/components/parameters/streetlightId'
|
|
89
|
+
publish:
|
|
90
|
+
message:
|
|
91
|
+
$ref: '#/components/messages/lightMeasured'
|
|
92
|
+
'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on':
|
|
93
|
+
parameters:
|
|
94
|
+
streetlightId:
|
|
95
|
+
$ref: '#/components/parameters/streetlightId'
|
|
96
|
+
subscribe:
|
|
97
|
+
message:
|
|
98
|
+
$ref: '#/components/messages/turnOnOff'
|
|
99
|
+
'smartylighting/streetlights/1/0/action/{streetlightId}/turn/off':
|
|
100
|
+
parameters:
|
|
101
|
+
streetlightId:
|
|
102
|
+
$ref: '#/components/parameters/streetlightId'
|
|
103
|
+
subscribe:
|
|
104
|
+
message:
|
|
105
|
+
$ref: '#/components/messages/turnOnOff'
|
|
106
|
+
'smartylighting/streetlights/1/0/action/{streetlightId}/dim':
|
|
107
|
+
parameters:
|
|
108
|
+
streetlightId:
|
|
109
|
+
$ref: '#/components/parameters/streetlightId'
|
|
110
|
+
subscribe:
|
|
111
|
+
message:
|
|
112
|
+
$ref: '#/components/messages/dimLight'
|