Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@
"profile": "https://github.com/KhudaDad414",
"contributions": [
"code",
"bug"
"bug",
"test"
]
},
{
Expand Down Expand Up @@ -159,6 +160,15 @@
"contributions": [
"test"
]
},
{
"login": "iamdevelopergirl",
"name": "Elakya",
"avatar_url": "https://avatars.githubusercontent.com/u/16351809?v=4",
"profile": "https://iamdevelopergirl.github.io/Website-With-Animations/",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 4,
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/automerge-orphans.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ jobs:
script: |
const query = `query($owner:String!, $name:String!) {
repository(owner:$owner, name:$name){
pullRequests(first: 100){
pullRequests(first: 100, states: OPEN){
nodes{
title
url
author {
resourcePath
}
state
}
}
}
Expand All @@ -38,7 +37,7 @@ jobs:
};
const { repository: { pullRequests: { nodes } } } = await github.graphql(query, variables);

let orphans = nodes.filter((pr)=> pr.state === 'OPEN' && (pr.author.resourcePath === '/asyncapi-bot' || pr.author.resourcePath === '/apps/dependabot'))
let orphans = nodes.filter( (pr) => pr.author.resourcePath === '/asyncapi-bot' || pr.author.resourcePath === '/apps/dependabot')

if (orphans.length) {
core.setOutput('found', 'true');
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
steps:
- name: Autoapproving
uses: hmarr/auto-approve-action@v2
if: github.actor == 'asyncapi-bot' || github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
if: github.actor == ('asyncapi-bot' || github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]') && !contains(github.event.pull_request.labels.*.name, 'released')
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

Expand All @@ -44,4 +44,4 @@ jobs:
MERGE_METHOD: "squash"
MERGE_COMMIT_MESSAGE: "pull-request-title"
MERGE_RETRIES: "20"
MERGE_RETRY_SLEEP: "20000"
MERGE_RETRY_SLEEP: "30000"
26 changes: 13 additions & 13 deletions .github/workflows/bump.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
name: Bump package version in dependent repos
#This action is centrally managed in https://github.com/asyncapi/.github/
#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

#Purpose of this action is to update npm package in libraries that use it. It is like dependabot for asyncapi npm modules only.
#It runs in a repo after merge of release commit and searches for other packages that use released package. Every found package gets updated with lates version

name: Bump package version in dependent repos - if Node project

on:
#It cannot run on release event as when release is created then version is not yet bumped in package.json
Expand All @@ -13,20 +19,14 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Get version from package.json before release step
id: extractver
run: echo "::set-output name=version::$(npm run get:version --silent)"
- name: Get name of package from package.json
id: extractname
run: echo "::set-output name=packname::$(npm run get:name --silent)"
- if: startsWith(github.event.commits[0].message, 'chore(release):')
- name: Check if Node.js project and has package.json
id: packagejson
run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false"
- if: steps.packagejson.outputs.exists == 'true' && startsWith(github.event.commits[0].message, 'chore(release):')
name: Bumping latest version of this package in other repositories
uses: derberg/org-projects-dependency-manager@v1
uses: derberg/npm-dependency-manager-for-your-github-org@v3
with:
github_token: ${{ secrets.GH_TOKEN }}
committer_username: asyncapi-bot
committer_email: info@asyncapi.io
#This is commit message and PR title for repos where this package is in dependencies
commit_message_prod: 'fix: update ${{ steps.extractname.outputs.packname }} to ${{ steps.extractver.outputs.version }} version'
#This is commit message and PR title for repos where this package is in devDependencies
commit_message_dev: 'chore: update ${{ steps.extractname.outputs.packname }} to ${{ steps.extractver.outputs.version }} version'
repos_to_ignore: html-template #this is temporary until react component releases 1.0, then it can be removed
23 changes: 23 additions & 0 deletions .github/workflows/issues-prs-notifications.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#This action is centrally managed in https://github.com/asyncapi/.github/
#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

#This action notifies community on slack whenever there is a new issue, PR or discussion started in given repository
name: Notify slack

on:
Expand All @@ -10,6 +12,9 @@ on:
pull_request_target:
types: [opened, reopened, ready_for_review]

discussion:
types: [opened]

jobs:

issue:
Expand Down Expand Up @@ -47,3 +52,21 @@ jobs:
SLACK_TITLE: 💪 New Pull Request 💪
SLACK_MESSAGE: ${{steps.prmarkdown.outputs.text}}
MSG_MINIMAL: true

discussion:
if: github.event_name == 'discussion' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
name: On every new pull request
runs-on: ubuntu-latest
steps:
- name: Convert markdown to slack markdown for pull request
uses: LoveToKnow/slackify-markdown-action@v1.0.0
id: discussionmarkdown
with:
text: "[${{github.event.discussion.title}}](${{github.event.discussion.html_url}}) \n ${{github.event.discussion.body}}"
- name: Send info about pull request
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}}
SLACK_TITLE: 💬 New Discussion 💬
SLACK_MESSAGE: ${{steps.discussionmarkdown.outputs.text}}
MSG_MINIMAL: true
54 changes: 45 additions & 9 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@
* [.Message](#module_@asyncapi/parser+Message) ⇐ <code>MessageTraitable</code>
* [.uid()](#module_@asyncapi/parser+Message+uid) ⇒ <code>string</code>
* [.payload()](#module_@asyncapi/parser+Message+payload) ⇒ <code>Schema</code>
* [.traits()](#module_@asyncapi/parser+Message+traits) ⇒ <code>Array.&lt;MessageTrait&gt;</code>
* [.hasTraits()](#module_@asyncapi/parser+Message+hasTraits) ⇒ <code>boolean</code>
* [.originalPayload()](#module_@asyncapi/parser+Message+originalPayload) ⇒ <code>any</code>
* [.originalSchemaFormat()](#module_@asyncapi/parser+Message+originalSchemaFormat) ⇒ <code>string</code>
* [.OAuthFlow](#module_@asyncapi/parser+OAuthFlow) ⇐ <code>Base</code>
Expand Down Expand Up @@ -250,6 +252,8 @@
* [.ext(key)](#module_@asyncapi/parser+OperationTraitable+ext) ⇒ <code>any</code>
* [.Operation](#module_@asyncapi/parser+Operation) ⇐ <code>OperationTraitable</code>
* [.hasMultipleMessages()](#module_@asyncapi/parser+Operation+hasMultipleMessages) ⇒ <code>boolean</code>
* [.traits()](#module_@asyncapi/parser+Operation+traits) ⇒ <code>Array.&lt;OperationTrait&gt;</code>
* [.hasTraits()](#module_@asyncapi/parser+Operation+hasTraits) ⇒ <code>boolean</code>
* [.messages()](#module_@asyncapi/parser+Operation+messages) ⇒ <code>Array.&lt;Message&gt;</code>
* [.message()](#module_@asyncapi/parser+Operation+message) ⇒ <code>Message</code>
* [.PublishOperation](#module_@asyncapi/parser+PublishOperation) ⇐ <code>Operation</code>
Expand Down Expand Up @@ -458,6 +462,7 @@
* [~parse(asyncapiYAMLorJSON, [options])](#module_@asyncapi/parser..parse) ⇒ <code>Promise.&lt;AsyncAPIDocument&gt;</code>
* [~parseFromUrl(url, [fetchOptions], [options])](#module_@asyncapi/parser..parseFromUrl) ⇒ <code>Promise.&lt;AsyncAPIDocument&gt;</code>
* [~registerSchemaParser(parserModule)](#module_@asyncapi/parser..registerSchemaParser)
* [~ParserOptions](#module_@asyncapi/parser..ParserOptions) : <code>Object</code>

<a name="module_@asyncapi/parser+ChannelParameter"></a>

Expand Down Expand Up @@ -1692,6 +1697,8 @@ Implements functions to deal with a Message object.
* [.Message](#module_@asyncapi/parser+Message) ⇐ <code>MessageTraitable</code>
* [.uid()](#module_@asyncapi/parser+Message+uid) ⇒ <code>string</code>
* [.payload()](#module_@asyncapi/parser+Message+payload) ⇒ <code>Schema</code>
* [.traits()](#module_@asyncapi/parser+Message+traits) ⇒ <code>Array.&lt;MessageTrait&gt;</code>
* [.hasTraits()](#module_@asyncapi/parser+Message+hasTraits) ⇒ <code>boolean</code>
* [.originalPayload()](#module_@asyncapi/parser+Message+originalPayload) ⇒ <code>any</code>
* [.originalSchemaFormat()](#module_@asyncapi/parser+Message+originalSchemaFormat) ⇒ <code>string</code>

Expand All @@ -1703,6 +1710,14 @@ Implements functions to deal with a Message object.

#### message.payload() ⇒ <code>Schema</code>
**Kind**: instance method of [<code>Message</code>](#module_@asyncapi/parser+Message)
<a name="module_@asyncapi/parser+Message+traits"></a>

#### message.traits() ⇒ <code>Array.&lt;MessageTrait&gt;</code>
**Kind**: instance method of [<code>Message</code>](#module_@asyncapi/parser+Message)
<a name="module_@asyncapi/parser+Message+hasTraits"></a>

#### message.hasTraits() ⇒ <code>boolean</code>
**Kind**: instance method of [<code>Message</code>](#module_@asyncapi/parser+Message)
<a name="module_@asyncapi/parser+Message+originalPayload"></a>

#### message.originalPayload() ⇒ <code>any</code>
Expand Down Expand Up @@ -2020,13 +2035,23 @@ Implements functions to deal with an Operation object.

* [.Operation](#module_@asyncapi/parser+Operation) ⇐ <code>OperationTraitable</code>
* [.hasMultipleMessages()](#module_@asyncapi/parser+Operation+hasMultipleMessages) ⇒ <code>boolean</code>
* [.traits()](#module_@asyncapi/parser+Operation+traits) ⇒ <code>Array.&lt;OperationTrait&gt;</code>
* [.hasTraits()](#module_@asyncapi/parser+Operation+hasTraits) ⇒ <code>boolean</code>
* [.messages()](#module_@asyncapi/parser+Operation+messages) ⇒ <code>Array.&lt;Message&gt;</code>
* [.message()](#module_@asyncapi/parser+Operation+message) ⇒ <code>Message</code>

<a name="module_@asyncapi/parser+Operation+hasMultipleMessages"></a>

#### operation.hasMultipleMessages() ⇒ <code>boolean</code>
**Kind**: instance method of [<code>Operation</code>](#module_@asyncapi/parser+Operation)
<a name="module_@asyncapi/parser+Operation+traits"></a>

#### operation.traits() ⇒ <code>Array.&lt;OperationTrait&gt;</code>
**Kind**: instance method of [<code>Operation</code>](#module_@asyncapi/parser+Operation)
<a name="module_@asyncapi/parser+Operation+hasTraits"></a>

#### operation.hasTraits() ⇒ <code>boolean</code>
**Kind**: instance method of [<code>Operation</code>](#module_@asyncapi/parser+Operation)
<a name="module_@asyncapi/parser+Operation+messages"></a>

#### operation.messages() ⇒ <code>Array.&lt;Message&gt;</code>
Expand Down Expand Up @@ -3437,14 +3462,10 @@ Parses and validate an AsyncAPI document from YAML or JSON.
**Kind**: inner method of [<code>@asyncapi/parser</code>](#module_@asyncapi/parser)
**Returns**: <code>Promise.&lt;AsyncAPIDocument&gt;</code> - The parsed AsyncAPI document.

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| asyncapiYAMLorJSON | <code>String</code> \| <code>Object</code> | | An AsyncAPI document in JSON or YAML format. |
| [options] | <code>Object</code> | | Configuration options. |
| [options.path] | <code>String</code> | | Path to the AsyncAPI document. It will be used to resolve relative references. Defaults to current working dir. |
| [options.parse] | <code>Object</code> | | Options object to pass to [json-schema-ref-parser](https://apidevtools.org/json-schema-ref-parser/docs/options.html). |
| [options.resolve] | <code>Object</code> | | Options object to pass to [json-schema-ref-parser](https://apidevtools.org/json-schema-ref-parser/docs/options.html). |
| [options.applyTraits] | <code>Object</code> | <code>true</code> | Whether to resolve and apply traits or not. |
| Param | Type | Description |
| --- | --- | --- |
| asyncapiYAMLorJSON | <code>String</code> \| <code>Object</code> | An AsyncAPI document in JSON or YAML format. |
| [options] | <code>ParserOptions</code> | Configuration options object [ParserOptions](ParserOptions) |

<a name="module_@asyncapi/parser..parseFromUrl"></a>

Expand All @@ -3458,7 +3479,7 @@ Fetches an AsyncAPI document from the given URL and passes its content to the `p
| --- | --- | --- |
| url | <code>String</code> | URL where the AsyncAPI document is located. |
| [fetchOptions] | <code>Object</code> | Configuration to pass to the [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Request) call. |
| [options] | <code>Object</code> | Configuration to pass to the [module:Parser#parse](module:Parser#parse) method. |
| [options] | <code>ParserOptions</code> | Configuration to pass to the [ParserOptions](ParserOptions) method. |

<a name="module_@asyncapi/parser..registerSchemaParser"></a>

Expand All @@ -3471,6 +3492,21 @@ Registers a new schema parser. Schema parsers are in charge of parsing and trans
| --- | --- | --- |
| parserModule | <code>Object</code> | The schema parser module containing parse() and getMimeTypes() functions. |

<a name="module_@asyncapi/parser..ParserOptions"></a>

### @asyncapi/parser~ParserOptions : <code>Object</code>
The complete list of parse configuration options used to parse the given data.

**Kind**: inner typedef of [<code>@asyncapi/parser</code>](#module_@asyncapi/parser)
**Properties**

| Name | Type | Description |
| --- | --- | --- |
| [path] | <code>String</code> | Path to the AsyncAPI document. It will be used to resolve relative references. Defaults to current working dir. |
| [parse] | <code>Object</code> | Options object to pass to [json-schema-ref-parser](https://apidevtools.org/json-schema-ref-parser/docs/options.html). |
| [resolve] | <code>Object</code> | Options object to pass to [json-schema-ref-parser](https://apidevtools.org/json-schema-ref-parser/docs/options.html). |
| [applyTraits] | <code>Boolean</code> | Whether to resolve and apply traits or not. Defaults to true. |

<a name="MixinBindings"></a>

## MixinBindings
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2019 Francisco Méndez Vilas
Copyright The Linux Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,13 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tr>
<td align="center"><a href="https://www.linkedin.com/in/jbreitenbaumer/"><img src="https://avatars3.githubusercontent.com/u/683438?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jürgen B.</b></sub></a><br /><a href="https://github.com/asyncapi/parser-js/commits?author=juergenbr" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/aeworxet"><img src="https://avatars.githubusercontent.com/u/16149591?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Viacheslav Turovskyi</b></sub></a><br /><a href="https://github.com/asyncapi/parser-js/commits?author=aeworxet" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/KhudaDad414"><img src="https://avatars.githubusercontent.com/u/32505158?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Khuda Dad Nomani</b></sub></a><br /><a href="https://github.com/asyncapi/parser-js/commits?author=KhudaDad414" title="Code">💻</a> <a href="https://github.com/asyncapi/parser-js/issues?q=author%3AKhudaDad414" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/KhudaDad414"><img src="https://avatars.githubusercontent.com/u/32505158?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Khuda Dad Nomani</b></sub></a><br /><a href="https://github.com/asyncapi/parser-js/commits?author=KhudaDad414" title="Code">💻</a> <a href="https://github.com/asyncapi/parser-js/issues?q=author%3AKhudaDad414" title="Bug reports">🐛</a> <a href="https://github.com/asyncapi/parser-js/commits?author=KhudaDad414" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/aayushmau5"><img src="https://avatars.githubusercontent.com/u/54525741?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aayush Kumar Sahu</b></sub></a><br /><a href="https://github.com/asyncapi/parser-js/commits?author=aayushmau5" title="Tests">⚠️</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/JQrdan"><img src="https://avatars.githubusercontent.com/u/25624685?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jordan Tucker</b></sub></a><br /><a href="https://github.com/asyncapi/parser-js/commits?author=JQrdan" title="Tests">⚠️</a> <a href="https://github.com/asyncapi/parser-js/commits?author=JQrdan" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/vishesh13byte"><img src="https://avatars.githubusercontent.com/u/66796715?v=4?s=100" width="100px;" alt=""/><br /><sub><b>vishesh13byte</b></sub></a><br /><a href="https://github.com/asyncapi/parser-js/commits?author=vishesh13byte" title="Tests">⚠️</a></td>
<td align="center"><a href="https://iamdevelopergirl.github.io/Website-With-Animations/"><img src="https://avatars.githubusercontent.com/u/16351809?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elakya</b></sub></a><br /><a href="https://github.com/asyncapi/parser-js/commits?author=iamdevelopergirl" title="Code">💻</a></td>
</tr>
</table>

Expand Down
2 changes: 1 addition & 1 deletion dist/bundle.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions lib/asyncapiSchemaFormatParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ function getMimeTypes() {
return [
'application/vnd.aai.asyncapi;version=2.0.0',
'application/vnd.aai.asyncapi;version=2.1.0',
'application/vnd.aai.asyncapi;version=2.2.0',
'application/vnd.aai.asyncapi+json;version=2.0.0',
'application/vnd.aai.asyncapi+json;version=2.1.0',
'application/vnd.aai.asyncapi+json;version=2.2.0',
'application/vnd.aai.asyncapi+yaml;version=2.0.0',
'application/vnd.aai.asyncapi+yaml;version=2.1.0',
'application/vnd.aai.asyncapi+yaml;version=2.2.0',
'application/schema;version=draft-07',
'application/schema+json;version=draft-07',
'application/schema+yaml;version=draft-07',
Expand Down
17 changes: 17 additions & 0 deletions lib/models/message.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const MessageTrait = require('./message-trait');
const MessageTraitable = require('./message-traitable');
const Schema = require('./schema');

Expand All @@ -24,6 +25,22 @@ class Message extends MessageTraitable {
return new Schema(this._json.payload);
}

/**
* @returns {MessageTrait[]}
*/
traits() {
const traits = this._json['x-parser-original-traits'] || this._json.traits;
if (!traits) return [];
return traits.map(t => new MessageTrait(t));
}

/**
* @returns {boolean}
*/
hasTraits() {
return !!this._json['x-parser-original-traits'] || !!this._json.traits;
}

/**
* @returns {any}
*/
Expand Down
Loading