diff --git a/.github/workflows/bump.yml b/.github/workflows/bump.yml index dff50cfa..1e17ccf2 100644 --- a/.github/workflows/bump.yml +++ b/.github/workflows/bump.yml @@ -26,9 +26,10 @@ jobs: run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT - if: steps.packagejson.outputs.exists == 'true' name: Bumping latest version of this package in other repositories - uses: derberg/npm-dependency-manager-for-your-github-org@3df56be95bcaa5c76a9c9a4af863ab151545b649 # using v6.-.- https://github.com/derberg/npm-dependency-manager-for-your-github-org/releases/tag/v6 + uses: derberg/npm-dependency-manager-for-your-github-org@1eafd3bf3974f21d395c1abac855cb04b295d570 # using v6.-.- https://github.com/derberg/npm-dependency-manager-for-your-github-org/releases/tag/v6 with: github_token: ${{ secrets.GH_TOKEN }} committer_username: asyncapi-bot committer_email: info@asyncapi.io repos_to_ignore: spec,bindings,saunter + custom_id: "dependency update from asyncapi bot" diff --git a/.github/workflows/help-command.yml b/.github/workflows/help-command.yml index d4ba4a44..55353bb8 100644 --- a/.github/workflows/help-command.yml +++ b/.github/workflows/help-command.yml @@ -31,6 +31,7 @@ jobs: At the moment the following comments are supported in pull requests: + - \`/please-take-a-look\` or \`/ptal\` - This comment will add a comment to the PR asking for attention from the reviewrs who have not reviewed the PR yet. - \`/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 - \`/do-not-merge\` or \`/dnm\` - This comment will block automerging even if all conditions are met and ready-to-merge label is added - \`/autoupdate\` or \`/au\` - This comment will add \`autoupdate\` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR.` diff --git a/.github/workflows/if-nodejs-pr-testing.yml b/.github/workflows/if-nodejs-pr-testing.yml index 691f8350..66ea6552 100644 --- a/.github/workflows/if-nodejs-pr-testing.yml +++ b/.github/workflows/if-nodejs-pr-testing.yml @@ -33,14 +33,16 @@ jobs: id: should_run name: Should Run run: echo "shouldrun=true" >> $GITHUB_OUTPUT + shell: bash - if: steps.should_run.outputs.shouldrun == 'true' name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows run: | git config --global core.autocrlf false git config --global core.eol lf + shell: bash - if: steps.should_run.outputs.shouldrun == 'true' name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - if: steps.should_run.outputs.shouldrun == 'true' name: Check if Node.js project and has package.json id: packagejson @@ -52,27 +54,26 @@ jobs: id: lockversion - if: steps.packagejson.outputs.exists == 'true' name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "${{ steps.lockversion.outputs.version }}" - cache: 'npm' - cache-dependency-path: '**/package-lock.json' + - if: steps.lockversion.outputs.version == '18' && matrix.os == 'windows-latest' + #npm cli 10 is buggy because of some cache issue + name: Install npm cli 8 + shell: bash + run: npm install -g npm@8.19.4 - if: steps.packagejson.outputs.exists == 'true' name: Install dependencies - id: first-installation - run: npm install --loglevel verbose - continue-on-error: true - - if: steps.first-installation.outputs.status == 'failure' && steps.packagejson.outputs.exists == 'true' - name: Clear NPM cache and install deps again - run: | - npm cache clean --force - npm install --loglevel verbose + shell: bash + run: npm ci - if: steps.packagejson.outputs.exists == 'true' name: Test run: npm test --if-present - - if: steps.packagejson.outputs.exists == 'true' + - if: steps.packagejson.outputs.exists == 'true' && matrix.os == 'ubuntu-latest' + #linting should run just one and not on all possible operating systems name: Run linter run: npm run lint --if-present - if: steps.packagejson.outputs.exists == 'true' name: Run release assets generation to make sure PR does not break it - run: npm run generate:assets --if-present \ No newline at end of file + shell: bash + run: npm run generate:assets --if-present diff --git a/.github/workflows/if-nodejs-release.yml b/.github/workflows/if-nodejs-release.yml index 4938a37d..234c5a9c 100644 --- a/.github/workflows/if-nodejs-release.yml +++ b/.github/workflows/if-nodejs-release.yml @@ -38,8 +38,9 @@ jobs: run: | git config --global core.autocrlf false git config --global core.eol lf + shell: bash - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Check if Node.js project and has package.json id: packagejson run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT @@ -50,14 +51,18 @@ jobs: id: lockversion - if: steps.packagejson.outputs.exists == 'true' name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "${{ steps.lockversion.outputs.version }}" - cache: 'npm' - cache-dependency-path: '**/package-lock.json' + - if: steps.lockversion.outputs.version == '18' && matrix.os == 'windows-latest' + name: Install npm cli 8 + shell: bash + #npm cli 10 is buggy because of some cache issues + run: npm install -g npm@8.19.4 - if: steps.packagejson.outputs.exists == 'true' name: Install dependencies - run: npm install + shell: bash + run: npm ci - if: steps.packagejson.outputs.exists == 'true' name: Run test run: npm test --if-present @@ -81,24 +86,24 @@ jobs: git config --global core.autocrlf false git config --global core.eol lf - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Check if Node.js project and has package.json id: packagejson run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT + shell: bash - if: steps.packagejson.outputs.exists == 'true' name: Check package-lock version uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master id: lockversion - if: steps.packagejson.outputs.exists == 'true' name: Setup Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "${{ steps.lockversion.outputs.version }}" - cache: 'npm' - cache-dependency-path: '**/package-lock.json' - if: steps.packagejson.outputs.exists == 'true' name: Install dependencies - run: npm install + shell: bash + run: npm ci - if: steps.packagejson.outputs.exists == 'true' name: Add plugin for conventional commits for semantic-release run: npm install --save-dev conventional-changelog-conventionalcommits@5.0.0 @@ -123,4 +128,4 @@ jobs: fields: repo,action,workflow text: 'Release workflow failed in release job' env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} \ No newline at end of file diff --git a/.github/workflows/if-nodejs-version-bump.yml b/.github/workflows/if-nodejs-version-bump.yml index 7e27f90b..36847d80 100644 --- a/.github/workflows/if-nodejs-version-bump.yml +++ b/.github/workflows/if-nodejs-version-bump.yml @@ -37,7 +37,7 @@ jobs: cache-dependency-path: '**/package-lock.json' - if: steps.packagejson.outputs.exists == 'true' name: Install dependencies - run: npm install + run: npm ci - if: steps.packagejson.outputs.exists == 'true' name: Assets generation run: npm run generate:assets --if-present diff --git a/.github/workflows/please-take-a-look-command.yml b/.github/workflows/please-take-a-look-command.yml new file mode 100644 index 00000000..b26cbc41 --- /dev/null +++ b/.github/workflows/please-take-a-look-command.yml @@ -0,0 +1,54 @@ +# 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 + +# It uses Github actions to listen for comments on issues and pull requests and +# if the comment contains /please-take-a-look or /ptal it will add a comment pinging +# the code-owners who are reviewers for PR + +name: Please take a Look + +on: + issue_comment: + types: [created] + +jobs: + ping-for-attention: + if: > + github.event.issue.pull_request && + github.event.issue.state != 'closed' && + github.actor != 'asyncapi-bot' && + ( + contains(github.event.comment.body, '/please-take-a-look') || + contains(github.event.comment.body, '/ptal') || + contains(github.event.comment.body, '/PTAL') + ) + runs-on: ubuntu-latest + steps: + - name: Check for Please Take a Look Command + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GH_TOKEN }} + script: | + const prDetailsUrl = context.payload.issue.pull_request.url; + const { data: pull } = await github.request(prDetailsUrl); + const reviewers = pull.requested_reviewers.map(reviewer => reviewer.login); + + const { data: reviews } = await github.rest.pulls.listReviews({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number + }); + + const reviewersWhoHaveReviewed = reviews.map(review => review.user.login); + + const reviewersWhoHaveNotReviewed = reviewers.filter(reviewer => !reviewersWhoHaveReviewed.includes(reviewer)); + + if (reviewersWhoHaveNotReviewed.length > 0) { + const comment = reviewersWhoHaveNotReviewed.filter(reviewer => reviewer !== 'asyncapi-bot-eve' ).map(reviewer => `@${reviewer}`).join(' '); + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `${comment} Please take a look at this PR. Thanks! :wave:` + }); + } diff --git a/.gitignore b/.gitignore index d4a20833..fc668545 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules .nyc_output .vscode -coverage \ No newline at end of file +coverage + +.DS_Store \ No newline at end of file diff --git a/CODEOWNERS b/CODEOWNERS index c6c77c26..f2346c90 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -6,7 +6,7 @@ # The default owners are automatically added as reviewers when you open a pull request unless different owners are specified in the file. -* @fmvilas @derberg @dalelane @smoya @char0n @asyncapi-bot-eve @GreenRover +* @fmvilas @derberg @dalelane @smoya @char0n @GreenRover @jonaslagoni @pakisan @asyncapi-bot-eve /bindings/anypointmq/ @mboss37 @GeraldLoeffler /bindings/ibmmq/ @rcoppen diff --git a/definitions/3.0.0/components.json b/definitions/3.0.0/components.json index 2d7b5e2f..2243d978 100644 --- a/definitions/3.0.0/components.json +++ b/definitions/3.0.0/components.json @@ -13,14 +13,7 @@ "description": "An object to hold reusable Schema Object. If this is a Schema Object, then the schemaFormat will be assumed to be 'application/vnd.aai.asyncapi+json;version=asyncapi' where the version is equal to the AsyncAPI Version String.", "patternProperties": { "^[\\w\\d\\.\\-_]+$": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json" - } - ] + "$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json" } } }, diff --git a/definitions/3.0.0/multiFormatSchema.json b/definitions/3.0.0/multiFormatSchema.json index d4047bb0..077cdcf6 100644 --- a/definitions/3.0.0/multiFormatSchema.json +++ b/definitions/3.0.0/multiFormatSchema.json @@ -1,5 +1,11 @@ { "description": "The Multi Format Schema Object represents a schema definition. It differs from the Schema Object in that it supports multiple schema formats or languages (e.g., JSON Schema, Avro, etc.).", + "type": "object", + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, "if": { "not": { "type": "object" @@ -9,13 +15,6 @@ "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" }, "else": { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^x-[\\w\\d\\.\\x2d_]+$": { - "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" - } - }, "properties": { "schemaFormat": { "description": "A string containing the name of the schema format that is used to define the information. If schemaFormat is missing, it MUST default to application/vnd.aai.asyncapi+json;version={{asyncapi}} where {{asyncapi}} matches the AsyncAPI Version String. In such a case, this would make the Multi Format Schema Object equivalent to the Schema Object. When using Reference Object within the schema, the schemaFormat of the resource being referenced MUST match the schemaFormat of the schema that contains the initial reference. For example, if you reference Avro schema, then schemaFormat of referencing resource and the resource being reference MUST match.", @@ -37,21 +36,18 @@ { "description": "All the schema formats tools are RECOMMENDED to support", "enum": [ - "application/vnd.oai.openapi;version=3.0.0", - "application/vnd.oai.openapi+json;version=3.0.0", + "application/vnd.oai.openapi;version=3.0.0", + "application/vnd.oai.openapi+json;version=3.0.0", "application/vnd.oai.openapi+yaml;version=3.0.0", - + "application/vnd.apache.avro;version=1.9.0", "application/vnd.apache.avro+json;version=1.9.0", "application/vnd.apache.avro+yaml;version=1.9.0", - + "application/raml+yaml;version=1.0" ] } ] - }, - "schema": { - "description": "Definition of the message payload. It can be of any type but defaults to Schema Object. It MUST match the schema format defined in schemaFormat, including the encoding type. E.g., Avro should be inlined as either a YAML or JSON object instead of as a string to be parsed as YAML or JSON. Non-JSON-based schemas (e.g., Protobuf or XSD) MUST be inlined as a string." } }, "allOf": [ @@ -67,14 +63,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" - } - ] + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" } } } @@ -119,14 +108,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" - } - ] + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" } } } @@ -148,14 +130,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://json-schema.org/draft-07/schema" - } - ] + "$ref": "http://json-schema.org/draft-07/schema" } } } diff --git a/definitions/3.0.0/operationBindingsObject.json b/definitions/3.0.0/operationBindingsObject.json index 26555d2d..dd1744d6 100644 --- a/definitions/3.0.0/operationBindingsObject.json +++ b/definitions/3.0.0/operationBindingsObject.json @@ -131,7 +131,7 @@ "kafka": { "properties": { "bindingVersion": { - "enum": ["0.4.0", "0.3.0"] + "enum": ["0.5.0", "0.4.0", "0.3.0"] } }, "allOf": [ diff --git a/definitions/3.0.0/serverBindingsObject.json b/definitions/3.0.0/serverBindingsObject.json index 2e65a2a0..91f8b90a 100644 --- a/definitions/3.0.0/serverBindingsObject.json +++ b/definitions/3.0.0/serverBindingsObject.json @@ -50,7 +50,7 @@ "kafka": { "properties": { "bindingVersion": { - "enum": ["0.4.0", "0.3.0"] + "enum": ["0.5.0", "0.4.0", "0.3.0"] } }, "allOf": [ diff --git a/go.mod b/go.mod index fdec2e5d..7b522bae 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/asyncapi/spec-json-schemas/v4 +module github.com/asyncapi/spec-json-schemas/v6 go 1.17 diff --git a/package-lock.json b/package-lock.json index 4e17dbf3..7100aae6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/specs", - "version": "6.5.3", + "version": "6.5.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@asyncapi/specs", - "version": "6.5.3", + "version": "6.5.6", "license": "Apache-2.0", "dependencies": { "@types/json-schema": "^7.0.11" diff --git a/package.json b/package.json index 3aecff62..652fb441 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@asyncapi/specs", - "version": "6.5.3", + "version": "6.5.6", "description": "AsyncAPI schema versions", "main": "index.js", "types": "index.d.ts", diff --git a/schemas/3.0.0-without-$id.json b/schemas/3.0.0-without-$id.json index 398d434a..297899e2 100644 --- a/schemas/3.0.0-without-$id.json +++ b/schemas/3.0.0-without-$id.json @@ -1211,6 +1211,7 @@ "properties": { "bindingVersion": { "enum": [ + "0.5.0", "0.4.0", "0.3.0" ] @@ -2055,7 +2056,7 @@ "properties": { "type": "array", "items": { - "$ref": "#/definitions/bindings-jms-0.0.1-server" + "$ref": "#/definitions/bindings-jms-0.0.1-server/definitions/property" }, "description": "Additional properties to set on the JMS ConnectionFactory implementation for the JMS Provider." }, @@ -2701,6 +2702,12 @@ }, "multiFormatSchema": { "description": "The Multi Format Schema Object represents a schema definition. It differs from the Schema Object in that it supports multiple schema formats or languages (e.g., JSON Schema, Avro, etc.).", + "type": "object", + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "#/definitions/specificationExtension" + } + }, "if": { "not": { "type": "object" @@ -2710,13 +2717,6 @@ "$ref": "#/definitions/schema" }, "else": { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^x-[\\w\\d\\.\\x2d_]+$": { - "$ref": "#/definitions/specificationExtension" - } - }, "properties": { "schemaFormat": { "description": "A string containing the name of the schema format that is used to define the information. If schemaFormat is missing, it MUST default to application/vnd.aai.asyncapi+json;version={{asyncapi}} where {{asyncapi}} matches the AsyncAPI Version String. In such a case, this would make the Multi Format Schema Object equivalent to the Schema Object. When using Reference Object within the schema, the schemaFormat of the resource being referenced MUST match the schemaFormat of the schema that contains the initial reference. For example, if you reference Avro schema, then schemaFormat of referencing resource and the resource being reference MUST match.", @@ -2747,9 +2747,6 @@ ] } ] - }, - "schema": { - "description": "Definition of the message payload. It can be of any type but defaults to Schema Object. It MUST match the schema format defined in schemaFormat, including the encoding type. E.g., Avro should be inlined as either a YAML or JSON object instead of as a string to be parsed as YAML or JSON. Non-JSON-based schemas (e.g., Protobuf or XSD) MUST be inlined as a string." } }, "allOf": [ @@ -2765,14 +2762,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "#/definitions/Reference" - }, - { - "$ref": "#/definitions/schema" - } - ] + "$ref": "#/definitions/schema" } } } @@ -2817,14 +2807,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "#/definitions/Reference" - }, - { - "$ref": "#/definitions/schema" - } - ] + "$ref": "#/definitions/schema" } } } @@ -2846,14 +2829,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "#/definitions/Reference" - }, - { - "$ref": "#/definitions/json-schema-draft-07-schema" - } - ] + "$ref": "#/definitions/json-schema-draft-07-schema" } } } @@ -5718,10 +5694,10 @@ "description": "The name of the topic. Can be different from the channel name to allow flexibility around AWS resource naming limitations." }, "ordering": { - "$ref": "#/definitions/bindings-sns-0.1.0-channel" + "$ref": "#/definitions/bindings-sns-0.1.0-channel/definitions/ordering" }, "policy": { - "$ref": "#/definitions/bindings-sns-0.1.0-channel" + "$ref": "#/definitions/bindings-sns-0.1.0-channel/definitions/policy" }, "tags": { "type": "object", @@ -5776,7 +5752,7 @@ "type": "array", "description": "An array of statement objects, each of which controls a permission for this topic", "items": { - "$ref": "#/definitions/bindings-sns-0.1.0-channel" + "$ref": "#/definitions/bindings-sns-0.1.0-channel/definitions/statement" } } }, @@ -5863,11 +5839,11 @@ "properties": { "queue": { "description": "A definition of the queue that will be used as the channel.", - "$ref": "#/definitions/bindings-sqs-0.2.0-channel" + "$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/queue" }, "deadLetterQueue": { "description": "A definition of the queue that will be used for un-processable messages.", - "$ref": "#/definitions/bindings-sqs-0.2.0-channel" + "$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/queue" }, "bindingVersion": { "type": "string", @@ -5946,10 +5922,10 @@ "default": 345600 }, "redrivePolicy": { - "$ref": "#/definitions/bindings-sqs-0.2.0-channel" + "$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/redrivePolicy" }, "policy": { - "$ref": "#/definitions/bindings-sqs-0.2.0-channel" + "$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/policy" }, "tags": { "type": "object", @@ -5971,7 +5947,7 @@ }, "properties": { "deadLetterQueue": { - "$ref": "#/definitions/bindings-sqs-0.2.0-channel" + "$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/identifier" }, "maxReceiveCount": { "type": "integer", @@ -6015,7 +5991,7 @@ "type": "array", "description": "An array of statement objects, each of which controls a permission for this queue.", "items": { - "$ref": "#/definitions/bindings-sqs-0.2.0-channel" + "$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/statement" } } }, @@ -6902,6 +6878,7 @@ "properties": { "bindingVersion": { "enum": [ + "0.5.0", "0.4.0", "0.3.0" ] @@ -7636,19 +7613,19 @@ }, "properties": { "topic": { - "$ref": "#/definitions/bindings-sns-0.1.0-operation", + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/identifier", "description": "Often we can assume that the SNS Topic is the channel name-we provide this field in case the you need to supply the ARN, or the Topic name is not the channel name in the AsyncAPI document." }, "consumers": { "type": "array", "description": "The protocols that listen to this topic and their endpoints.", "items": { - "$ref": "#/definitions/bindings-sns-0.1.0-operation" + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/consumer" }, "minItems": 1 }, "deliveryPolicy": { - "$ref": "#/definitions/bindings-sns-0.1.0-operation", + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/deliveryPolicy", "description": "Policy for retries to HTTP. The field is the default for HTTP receivers of the SNS Topic which may be overridden by a specific consumer." }, "bindingVersion": { @@ -7716,7 +7693,7 @@ }, "endpoint": { "description": "The endpoint messages are delivered to.", - "$ref": "#/definitions/bindings-sns-0.1.0-operation" + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/identifier" }, "filterPolicy": { "type": "object", @@ -7757,10 +7734,10 @@ "description": "If true AWS SNS attributes are removed from the body, and for SQS, SNS message attributes are copied to SQS message attributes. If false the SNS attributes are included in the body." }, "redrivePolicy": { - "$ref": "#/definitions/bindings-sns-0.1.0-operation" + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/redrivePolicy" }, "deliveryPolicy": { - "$ref": "#/definitions/bindings-sns-0.1.0-operation", + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/deliveryPolicy", "description": "Policy for retries to HTTP. The parameter is for that SNS Subscription and overrides any policy on the SNS Topic." }, "displayName": { @@ -7832,7 +7809,7 @@ }, "properties": { "deadLetterQueue": { - "$ref": "#/definitions/bindings-sns-0.1.0-operation", + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/identifier", "description": "The SQS queue to use as a dead letter queue (DLQ)." }, "maxReceiveCount": { @@ -7910,7 +7887,7 @@ "type": "array", "description": "Queue objects that are either the endpoint for an SNS Operation Binding Object, or the deadLetterQueue of the SQS Operation Binding Object.", "items": { - "$ref": "#/definitions/bindings-sqs-0.2.0-operation" + "$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/queue" } }, "bindingVersion": { @@ -7994,10 +7971,10 @@ "default": 345600 }, "redrivePolicy": { - "$ref": "#/definitions/bindings-sqs-0.2.0-operation" + "$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/redrivePolicy" }, "policy": { - "$ref": "#/definitions/bindings-sqs-0.2.0-operation" + "$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/policy" }, "tags": { "type": "object", @@ -8018,7 +7995,7 @@ }, "properties": { "deadLetterQueue": { - "$ref": "#/definitions/bindings-sqs-0.2.0-operation" + "$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/identifier" }, "maxReceiveCount": { "type": "integer", @@ -8062,7 +8039,7 @@ "type": "array", "description": "An array of statement objects, each of which controls a permission for this queue.", "items": { - "$ref": "#/definitions/bindings-sqs-0.2.0-operation" + "$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/statement" } } }, @@ -8514,14 +8491,7 @@ "description": "An object to hold reusable Schema Object. If this is a Schema Object, then the schemaFormat will be assumed to be 'application/vnd.aai.asyncapi+json;version=asyncapi' where the version is equal to the AsyncAPI Version String.", "patternProperties": { "^[\\w\\d\\.\\-_]+$": { - "oneOf": [ - { - "$ref": "#/definitions/Reference" - }, - { - "$ref": "#/definitions/anySchema" - } - ] + "$ref": "#/definitions/anySchema" } } }, diff --git a/schemas/3.0.0.json b/schemas/3.0.0.json index 9fb59b7e..25bbc016 100644 --- a/schemas/3.0.0.json +++ b/schemas/3.0.0.json @@ -1244,6 +1244,7 @@ "properties": { "bindingVersion": { "enum": [ + "0.5.0", "0.4.0", "0.3.0" ] @@ -2752,6 +2753,12 @@ "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json": { "$id": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json", "description": "The Multi Format Schema Object represents a schema definition. It differs from the Schema Object in that it supports multiple schema formats or languages (e.g., JSON Schema, Avro, etc.).", + "type": "object", + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, "if": { "not": { "type": "object" @@ -2761,13 +2768,6 @@ "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" }, "else": { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^x-[\\w\\d\\.\\x2d_]+$": { - "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" - } - }, "properties": { "schemaFormat": { "description": "A string containing the name of the schema format that is used to define the information. If schemaFormat is missing, it MUST default to application/vnd.aai.asyncapi+json;version={{asyncapi}} where {{asyncapi}} matches the AsyncAPI Version String. In such a case, this would make the Multi Format Schema Object equivalent to the Schema Object. When using Reference Object within the schema, the schemaFormat of the resource being referenced MUST match the schemaFormat of the schema that contains the initial reference. For example, if you reference Avro schema, then schemaFormat of referencing resource and the resource being reference MUST match.", @@ -2798,9 +2798,6 @@ ] } ] - }, - "schema": { - "description": "Definition of the message payload. It can be of any type but defaults to Schema Object. It MUST match the schema format defined in schemaFormat, including the encoding type. E.g., Avro should be inlined as either a YAML or JSON object instead of as a string to be parsed as YAML or JSON. Non-JSON-based schemas (e.g., Protobuf or XSD) MUST be inlined as a string." } }, "allOf": [ @@ -2816,14 +2813,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" - } - ] + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" } } } @@ -2868,14 +2858,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" - } - ] + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" } } } @@ -2897,14 +2880,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://json-schema.org/draft-07/schema" - } - ] + "$ref": "http://json-schema.org/draft-07/schema" } } } @@ -6990,6 +6966,7 @@ "properties": { "bindingVersion": { "enum": [ + "0.5.0", "0.4.0", "0.3.0" ] @@ -8616,14 +8593,7 @@ "description": "An object to hold reusable Schema Object. If this is a Schema Object, then the schemaFormat will be assumed to be 'application/vnd.aai.asyncapi+json;version=asyncapi' where the version is equal to the AsyncAPI Version String.", "patternProperties": { "^[\\w\\d\\.\\-_]+$": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json" - } - ] + "$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json" } } }, diff --git a/test/docs/3.0.0/streetlights-all.json b/test/docs/3.0.0/streetlights-all.json index 15b7cdc6..e0e3e781 100644 --- a/test/docs/3.0.0/streetlights-all.json +++ b/test/docs/3.0.0/streetlights-all.json @@ -6,7 +6,53 @@ "description": "This service is in charge of processing user signups" }, "channels": { - "UserSignedUpChannel": { + "AsyncAPI-UserSignedUpChannel": { + "address": "user/signedup/{test_param}", + "parameters": { + "test_param": { + "enum": [ + "test" + ], + "default": "test", + "description": "Just a test description", + "examples": [ + "test" + ], + "location": "$message.payload#", + "x-custom-extension": "test" + } + }, + "messages": { + "AsyncAPI-UserSignedUp": { + "$ref": "#/components/messages/AsyncAPI-UserSignedUp" + } + } + }, + "Avro-UserSignedUpChannel": { + "address": "user/signedup", + "messages": { + "UserSignedUp": { + "$ref": "#/components/messages/Avro-UserSignedUp" + } + } + }, + "Json-UserSignedUpChannel": { + "address": "user/signedup", + "messages": { + "UserSignedUp": { + "$ref": "#/components/messages/Json-UserSignedUp" + } + } + }, + "OpenAPI-UserSignedUpChannel": { + "address": "user/signedup", + "messages": { + "UserSignedUp": { + "$ref": "#/components/messages/OpenAPI-UserSignedUp" + } + } + }, + "Unknown-UserSignedUpChannel": { "address": "user/signedup/{test_param}", "parameters": { "test_param": { @@ -24,16 +70,96 @@ }, "messages": { "UserSignedUp": { - "$ref": "#/components/messages/UserSignedUp" + "$ref": "#/components/messages/Unknown-UserSignedUp" } } } }, "operations": { - "PublishUserSignedUp": { + "AsyncAPI-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/AsyncAPI-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "AsyncAPI-PublishUserSignedUpDefaultBinding": { + "action": "send", + "channel": { + "$ref": "#/channels/AsyncAPI-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Avro-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/Avro-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Avro-PublishUserSignedUpDefaultBinding": { "action": "send", "channel": { - "$ref": "#/channels/UserSignedUpChannel" + "$ref": "#/channels/Avro-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Json-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/Json-UserSignedUpChannel" }, "bindings": { "mqtt": { @@ -51,10 +177,90 @@ } } }, - "PublishUserSignedUpDefaultBinding": { + "Json-PublishUserSignedUpDefaultBinding": { "action": "send", "channel": { - "$ref": "#/channels/UserSignedUpChannel" + "$ref": "#/channels/Json-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "OpenAPI-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/OpenAPI-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "OpenAPI-PublishUserSignedUpDefaultBinding": { + "action": "send", + "channel": { + "$ref": "#/channels/OpenAPI-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Unknown-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/Unknown-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Unknown-PublishUserSignedUpDefaultBinding": { + "action": "send", + "channel": { + "$ref": "#/channels/Unknown-UserSignedUpChannel" }, "bindings": { "mqtt": { @@ -72,8 +278,85 @@ } }, "components": { + "schemas": { + "Avro-UserSignedUpHeaders": { + "schemaFormat": "application/vnd.apache.avro;version=1.9.0", + "schema": { + "fields": [ + { + "name": "applicationInstanceId", + "type": "string" + }, + { + "name": "correlationId", + "type": "string" + } + ], + "name": "UserSignedUpHeaders", + "namespace": "com.example.avro", + "type": "record" + } + }, + "Avro-ReferencedSchema": { + "schemaFormat": "application/vnd.apache.avro;version=1.9.0", + "schema": { + "$ref": "reference-to-some-avro-file.avsc" + } + }, + "Json-UserSignedUpHeaders": { + "schemaFormat": "application/schema+json;version=draft-07", + "schema": { + "type": "object", + "properties": { + "applicationInstanceId": { + "type": "string", + "description": "Application instance Id" + }, + "correlationId": { + "type": "string", + "description": "Correlation Id" + } + } + } + }, + "Json-ReferencedSchema": { + "schemaFormat": "application/schema+json;version=draft-07", + "schema": { + "$ref": "reference-to-some-json-schema-file.json" + } + }, + "OpenAPI-ReferencedSchema": { + "schemaFormat": "application/vnd.oai.openapi;version=3.0.0", + "schema": { + "$ref": "reference-to-some-openapi-file.json" + } + } + }, "messages": { - "UserSignedUp": { + "AsyncAPI-UserSignedUp": { + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "description": "Name of the user" + }, + "email": { + "type": "string", + "format": "email", + "description": "Email of the user" + } + }, + "externalDocs": { + "url": "https://account-service/docs/UserSignedUp" + }, + "deprecated": false + } + } + }, + "AsyncAPI-UserSignedUpV2": { "payload": { "type": "object", "properties": { @@ -86,10 +369,398 @@ "format": "email", "description": "Email of the user" } + }, + "externalDocs": { + "url": "https://account-service/docs/UserSignedUp" + }, + "deprecated": false + } + }, + "AsyncAPI-UserSignedUpV3": { + "payload": { + "$ref": "external-schema.json" + } + }, + "Avro-UserSignedUp": { + "headers": { + "$ref": "#/components/schemas/Avro-UserSignedUpHeaders" + }, + "payload": { + "schemaFormat": "application/vnd.apache.avro;version=1.9.0", + "schema": { + "doc": "This is a user record in a fictitious to-do-list management app. It supports arbitrary grouping and nesting of items, and allows you to add items by email or by tweeting.\n\nNote this app doesn't actually exist. The schema is just a demo for [Avrodoc](https://github.com/ept/avrodoc)!", + "fields": [ + { + "name": "id", + "doc": "System-assigned numeric user ID. Cannot be changed by the user.", + "type": "int" + }, + { + "name": "username", + "doc": "The username chosen by the user. Can be changed by the user.", + "type": "string" + }, + { + "name": "passwordHash", + "doc": "The user's password, hashed using [scrypt](http://www.tarsnap.com/scrypt.html).", + "type": "string" + }, + { + "name": "signupDate", + "doc": "Timestamp (milliseconds since epoch) when the user signed up", + "type": "long" + }, + { + "name": "emailAddresses", + "doc": "All email addresses on the user's account", + "type": { + "type": "array", + "items": { + "type": "record", + "name": "EmailAddress", + "doc": "Stores details about an email address that a user has associated with their account.", + "fields": [ + { + "name": "address", + "doc": "The email address, e.g. `foo@example.com`", + "type": "string" + }, + { + "name": "verified", + "doc": "true if the user has clicked the link in a confirmation email to this address.", + "type": "boolean", + "default": false + }, + { + "name": "dateAdded", + "doc": "Timestamp (milliseconds since epoch) when the email address was added to the account.", + "type": "long" + }, + { + "name": "dateBounced", + "doc": "Timestamp (milliseconds since epoch) when an email sent to this address last bounced. Reset to null when the address no longer bounces.", + "type": [ + "null", + "long" + ] + } + ] + } + } + }, + { + "name": "twitterAccounts", + "doc": "All Twitter accounts that the user has OAuthed", + "type": { + "type": "array", + "items": { + "type": "record", + "name": "TwitterAccount", + "doc": "Stores access credentials for one Twitter account, as granted to us by the user by OAuth.", + "fields": [ + { + "name": "status", + "doc": "Indicator of whether this authorization is currently active, or has been revoked", + "type": { + "type": "enum", + "name": "OAuthStatus", + "doc": "* `PENDING`: the user has started authorizing, but not yet finished\n* `ACTIVE`: the token should work\n* `DENIED`: the user declined the authorization\n* `EXPIRED`: the token used to work, but now it doesn't\n* `REVOKED`: the user has explicitly revoked the token", + "symbols": [ + "PENDING", + "ACTIVE", + "DENIED", + "EXPIRED", + "REVOKED" + ] + } + }, + { + "name": "userId", + "doc": "Twitter's numeric ID for this user", + "type": "long" + }, + { + "name": "screenName", + "doc": "The twitter username for this account (can be changed by the user)", + "type": "string" + }, + { + "name": "oauthToken", + "doc": "The OAuth token for this Twitter account", + "type": "string" + }, + { + "name": "oauthTokenSecret", + "doc": "The OAuth secret, used for signing requests on behalf of this Twitter account. `null` whilst the OAuth flow is not yet complete.", + "type": [ + "null", + "string" + ] + }, + { + "name": "dateAuthorized", + "doc": "Timestamp (milliseconds since epoch) when the user last authorized this Twitter account", + "type": "long" + } + ] + } + } + }, + { + "name": "toDoItems", + "doc": "The top-level items in the user's to-do list", + "type": { + "type": "array", + "items": { + "type": "record", + "name": "ToDoItem", + "doc": "A record is one node in a To-Do item tree (every record can contain nested sub-records).", + "fields": [ + { + "name": "status", + "doc": "User-selected state for this item (e.g. whether or not it is marked as done)", + "type": { + "type": "enum", + "name": "ToDoStatus", + "doc": "* `HIDDEN`: not currently visible, e.g. because it becomes actionable in future\n* `ACTIONABLE`: appears in the current to-do list\n* `DONE`: marked as done, but still appears in the list\n* `ARCHIVED`: marked as done and no longer visible\n* `DELETED`: not done and removed from list (preserved for undo purposes)", + "symbols": [ + "HIDDEN", + "ACTIONABLE", + "DONE", + "ARCHIVED", + "DELETED" + ] + } + }, + { + "name": "title", + "doc": "One-line summary of the item", + "type": "string" + }, + { + "name": "description", + "doc": "Detailed description (may contain HTML markup)", + "type": [ + "null", + "string" + ] + }, + { + "name": "snoozeDate", + "doc": "Timestamp (milliseconds since epoch) at which the item should go from `HIDDEN` to `ACTIONABLE` status", + "type": [ + "null", + "long" + ] + }, + { + "name": "subItems", + "doc": "List of children of this to-do tree node", + "type": { + "type": "array", + "items": "ToDoItem" + } + } + ] + } + } + } + ], + "name": "User", + "namespace": "com.example.avro", + "type": "record" + } + } + }, + "Json-UserSignedUp": { + "headers": { + "$ref": "#/components/schemas/Json-UserSignedUpHeaders" + }, + "payload": { + "schemaFormat": "application/schema+json;version=draft-07", + "schema": { + "type": "object", + "description": "This is a user record in a fictitious to-do-list management app. It supports arbitrary grouping and nesting of items, and allows you to add items by email or by tweeting.\n\nNote this app doesn't actually exist. The schema is just a demo for [Avrodoc](https://github.com/ept/avrodoc)!", + "properties": { + "id": { + "type": "integer", + "description": "System-assigned numeric user ID. Cannot be changed by the user." + }, + "username": { + "type": "string", + "description": "The username chosen by the user. Can be changed by the user." + }, + "passwordHash": { + "type": "string", + "description": "The user's password, hashed using [scrypt](http://www.tarsnap.com/scrypt.html)." + }, + "signupDate": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when the user signed up" + }, + "emailAddresses": { + "type": "array", + "description": "All email addresses on the user's account", + "items": { + "type": "object", + "description": "Stores details about an email address that a user has associated with their account.", + "properties": { + "address": { + "type": "string", + "description": "The email address, e.g. `foo@example.com`" + }, + "verified": { + "type": "boolean", + "description": "true if the user has clicked the link in a confirmation email to this address.", + "default": false + }, + "dateAdded": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when the email address was added to the account." + }, + "dateBounced": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when an email sent to this address last bounced. Reset to null when the address no longer bounces." + } + } + } + }, + "twitterAccounts": { + "type": "array", + "description": "All Twitter accounts that the user has OAuthed", + "items": { + "type": "object", + "description": "Stores access credentials for one Twitter account, as granted to us by the user by OAuth.", + "properties": { + "status": { + "type": "string", + "description": "Indicator of whether this authorization is currently active, or has been revoked", + "enum": [ + "PENDING", + "ACTIVE", + "DENIED", + "EXPIRED", + "REVOKED" + ] + }, + "userId": { + "type": "number", + "description": "Twitter's numeric ID for this user" + }, + "screenName": { + "type": "string", + "description": "The twitter username for this account (can be changed by the user)" + }, + "oauthToken": { + "type": "string", + "description": "The OAuth token for this Twitter account" + }, + "oauthTokenSecret": { + "type": "string", + "description": "The OAuth secret, used for signing requests on behalf of this Twitter account. `null` whilst the OAuth flow is not yet complete." + }, + "dateAuthorized": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when the user last authorized this Twitter account" + } + } + } + }, + "toDoItems": { + "type": "array", + "items": { + "type": "object", + "description": "A record is one node in a To-Do item tree (every record can contain nested sub-records).", + "properties": { + "status": { + "type": "string", + "description": "User-selected state for this item (e.g. whether or not it is marked as done)", + "enum": [ + "HIDDEN", + "ACTIONABLE", + "DONE", + "ARCHIVED", + "DELETED" + ] + }, + "title": { + "type": "string", + "description": "One-line summary of the item" + }, + "description": { + "type": "string", + "description": "Detailed description (may contain HTML markup)" + }, + "snoozeDate": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) at which the item should go from `HIDDEN` to `ACTIONABLE` status" + }, + "subItems": { + "type": "array", + "doc": "List of children of this to-do tree node", + "items": { + "$ref": "#/components/messages/UserSignedUp/payload/schema/properties/toDoItems" + } + } + } + } + } + } + } + } + }, + "OpenAPI-UserSignedUp": { + "payload": { + "schemaFormat": "application/vnd.oai.openapi;version=3.0.0", + "schema": { + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "completed": { + "type": "boolean" + }, + "completed_at": { + "type": "string", + "format": "date-time", + "nullable": true + } + }, + "required": [ + "id", + "name", + "completed" + ] + } + } + }, + "Unknown-UserSignedUp": { + "payload": { + "schemaFormat": "unknown-schema-format", + "schema": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "description": "Name of the user" + }, + "email": { + "type": "string", + "format": "email", + "description": "Email of the user" + } + }, + "externalDocs": { + "url": "https://account-service/docs/UserSignedUp" + }, + "deprecated": false } } }, - "UserSignedUpV2": { + "Unknown-UserSignedUpV2": { "payload": { "$ref": "external-schema.json" } diff --git a/test/docs/3.0.0/streetlights-asyncapi.json b/test/docs/3.0.0/streetlights-asyncapi.json new file mode 100644 index 00000000..c6885a2e --- /dev/null +++ b/test/docs/3.0.0/streetlights-asyncapi.json @@ -0,0 +1,126 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Account Service", + "version": "1.0.0", + "description": "This service is in charge of processing user signups" + }, + "channels": { + "AsyncAPI-UserSignedUpChannel": { + "address": "user/signedup/{test_param}", + "parameters": { + "test_param": { + "enum": [ + "test" + ], + "default": "test", + "description": "Just a test description", + "examples": [ + "test" + ], + "location": "$message.payload#", + "x-custom-extension": "test" + } + }, + "messages": { + "AsyncAPI-UserSignedUp": { + "$ref": "#/components/messages/AsyncAPI-UserSignedUp" + } + } + } + }, + "operations": { + "AsyncAPI-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/AsyncAPI-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "AsyncAPI-PublishUserSignedUpDefaultBinding": { + "action": "send", + "channel": { + "$ref": "#/channels/AsyncAPI-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + } + }, + "components": { + "messages": { + "AsyncAPI-UserSignedUp": { + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "description": "Name of the user" + }, + "email": { + "type": "string", + "format": "email", + "description": "Email of the user" + } + }, + "externalDocs": { + "url": "https://account-service/docs/UserSignedUp" + }, + "deprecated": false + } + } + }, + "AsyncAPI-UserSignedUpV2": { + "payload": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "description": "Name of the user" + }, + "email": { + "type": "string", + "format": "email", + "description": "Email of the user" + } + }, + "externalDocs": { + "url": "https://account-service/docs/UserSignedUp" + }, + "deprecated": false + } + }, + "AsyncAPI-UserSignedUpV3": { + "payload": { + "$ref": "external-schema.json" + } + } + } + } +} \ No newline at end of file diff --git a/test/docs/3.0.0/streetlights-avro.json b/test/docs/3.0.0/streetlights-avro.json index 34eed135..4396022b 100644 --- a/test/docs/3.0.0/streetlights-avro.json +++ b/test/docs/3.0.0/streetlights-avro.json @@ -6,20 +6,20 @@ "description": "This service is in charge of processing user signups" }, "channels": { - "UserSignedUpChannel": { + "Avro-UserSignedUpChannel": { "address": "user/signedup", "messages": { "UserSignedUp": { - "$ref": "#/components/messages/UserSignedUp" + "$ref": "#/components/messages/Avro-UserSignedUp" } } } }, "operations": { - "PublishUserSignedUp": { + "Avro-PublishUserSignedUp": { "action": "send", "channel": { - "$ref": "#/channels/UserSignedUpChannel" + "$ref": "#/channels/Avro-UserSignedUpChannel" }, "bindings": { "mqtt": { @@ -37,10 +37,10 @@ } } }, - "PublishUserSignedUpDefaultBinding": { + "Avro-PublishUserSignedUpDefaultBinding": { "action": "send", "channel": { - "$ref": "#/channels/UserSignedUpChannel" + "$ref": "#/channels/Avro-UserSignedUpChannel" }, "bindings": { "mqtt": { @@ -59,7 +59,7 @@ }, "components": { "schemas": { - "UserSignedUpHeaders": { + "Avro-UserSignedUpHeaders": { "schemaFormat": "application/vnd.apache.avro;version=1.9.0", "schema": { "fields": [ @@ -77,7 +77,7 @@ "type": "record" } }, - "ReferencedSchema" : { + "Avro-ReferencedSchema" : { "schemaFormat": "application/vnd.apache.avro;version=1.9.0", "schema": { "$ref": "reference-to-some-avro-file.avsc" @@ -85,9 +85,9 @@ } }, "messages": { - "UserSignedUp": { + "Avro-UserSignedUp": { "headers": { - "$ref": "#/components/schemas/UserSignedUpHeaders" + "$ref": "#/components/schemas/Avro-UserSignedUpHeaders" }, "payload": { "schemaFormat": "application/vnd.apache.avro;version=1.9.0", diff --git a/test/docs/3.0.0/streetlights-json.json b/test/docs/3.0.0/streetlights-json.json new file mode 100644 index 00000000..61b96152 --- /dev/null +++ b/test/docs/3.0.0/streetlights-json.json @@ -0,0 +1,225 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Account Service", + "version": "1.0.0", + "description": "This service is in charge of processing user signups" + }, + "channels": { + "Json-UserSignedUpChannel": { + "address": "user/signedup", + "messages": { + "UserSignedUp": { + "$ref": "#/components/messages/Json-UserSignedUp" + } + } + } + }, + "operations": { + "Json-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/Json-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Json-PublishUserSignedUpDefaultBinding": { + "action": "send", + "channel": { + "$ref": "#/channels/Json-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + } + }, + "components": { + "schemas": { + "Json-UserSignedUpHeaders": { + "schemaFormat": "application/schema+json;version=draft-07", + "schema": { + "type": "object", + "properties": { + "applicationInstanceId": { + "type": "string", + "description": "Application instance Id" + }, + "correlationId": { + "type": "string", + "description": "Correlation Id" + } + } + } + }, + "Json-ReferencedSchema" : { + "schemaFormat": "application/schema+json;version=draft-07", + "schema": { + "$ref": "reference-to-some-json-schema-file.json" + } + } + }, + "messages": { + "Json-UserSignedUp": { + "headers": { + "$ref": "#/components/schemas/Json-UserSignedUpHeaders" + }, + "payload": { + "schemaFormat": "application/schema+json;version=draft-07", + "schema": { + "type": "object", + "description": "This is a user record in a fictitious to-do-list management app. It supports arbitrary grouping and nesting of items, and allows you to add items by email or by tweeting.\n\nNote this app doesn't actually exist. The schema is just a demo for [Avrodoc](https://github.com/ept/avrodoc)!", + "properties": { + "id": { + "type": "integer", + "description": "System-assigned numeric user ID. Cannot be changed by the user." + }, + "username": { + "type": "string", + "description": "The username chosen by the user. Can be changed by the user." + }, + "passwordHash": { + "type": "string", + "description": "The user's password, hashed using [scrypt](http://www.tarsnap.com/scrypt.html)." + }, + "signupDate": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when the user signed up" + }, + "emailAddresses": { + "type": "array", + "description": "All email addresses on the user's account", + "items": { + "type": "object", + "description": "Stores details about an email address that a user has associated with their account.", + "properties": { + "address": { + "type": "string", + "description": "The email address, e.g. `foo@example.com`" + }, + "verified": { + "type": "boolean", + "description": "true if the user has clicked the link in a confirmation email to this address.", + "default": false + }, + "dateAdded": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when the email address was added to the account." + }, + "dateBounced": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when an email sent to this address last bounced. Reset to null when the address no longer bounces." + } + } + } + }, + "twitterAccounts": { + "type": "array", + "description": "All Twitter accounts that the user has OAuthed", + "items": { + "type": "object", + "description": "Stores access credentials for one Twitter account, as granted to us by the user by OAuth.", + "properties": { + "status": { + "type": "string", + "description": "Indicator of whether this authorization is currently active, or has been revoked", + "enum": [ + "PENDING", + "ACTIVE", + "DENIED", + "EXPIRED", + "REVOKED" + ] + }, + "userId": { + "type": "number", + "description": "Twitter's numeric ID for this user" + }, + "screenName": { + "type": "string", + "description": "The twitter username for this account (can be changed by the user)" + }, + "oauthToken": { + "type": "string", + "description": "The OAuth token for this Twitter account" + }, + "oauthTokenSecret": { + "type": "string", + "description": "The OAuth secret, used for signing requests on behalf of this Twitter account. `null` whilst the OAuth flow is not yet complete." + }, + "dateAuthorized": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when the user last authorized this Twitter account" + } + } + } + }, + "toDoItems": { + "type": "array", + "items": { + "type": "object", + "description": "A record is one node in a To-Do item tree (every record can contain nested sub-records).", + "properties": { + "status": { + "type": "string", + "description": "User-selected state for this item (e.g. whether or not it is marked as done)", + "enum": [ + "HIDDEN", + "ACTIONABLE", + "DONE", + "ARCHIVED", + "DELETED" + ] + }, + "title": { + "type": "string", + "description": "One-line summary of the item" + }, + "description": { + "type": "string", + "description": "Detailed description (may contain HTML markup)" + }, + "snoozeDate": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) at which the item should go from `HIDDEN` to `ACTIONABLE` status" + }, + "subItems": { + "type": "array", + "doc": "List of children of this to-do tree node", + "items": { + "$ref": "#/components/messages/UserSignedUp/payload/schema/properties/toDoItems" + } + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/test/docs/3.0.0/streetlights-openapi.json b/test/docs/3.0.0/streetlights-openapi.json index 08f25ae4..2d99bcb3 100644 --- a/test/docs/3.0.0/streetlights-openapi.json +++ b/test/docs/3.0.0/streetlights-openapi.json @@ -6,20 +6,20 @@ "description": "This service is in charge of processing user signups" }, "channels": { - "UserSignedUpChannel": { + "OpenAPI-UserSignedUpChannel": { "address": "user/signedup", "messages": { "UserSignedUp": { - "$ref": "#/components/messages/UserSignedUp" + "$ref": "#/components/messages/OpenAPI-UserSignedUp" } } } }, "operations": { - "PublishUserSignedUp": { + "OpenAPI-PublishUserSignedUp": { "action": "send", "channel": { - "$ref": "#/channels/UserSignedUpChannel" + "$ref": "#/channels/OpenAPI-UserSignedUpChannel" }, "bindings": { "mqtt": { @@ -37,10 +37,10 @@ } } }, - "PublishUserSignedUpDefaultBinding": { + "OpenAPI-PublishUserSignedUpDefaultBinding": { "action": "send", "channel": { - "$ref": "#/channels/UserSignedUpChannel" + "$ref": "#/channels/OpenAPI-UserSignedUpChannel" }, "bindings": { "mqtt": { @@ -59,7 +59,7 @@ }, "components": { "schemas": { - "ReferencedSchema" : { + "OpenAPI-ReferencedSchema" : { "schemaFormat": "application/vnd.oai.openapi;version=3.0.0", "schema": { "$ref": "reference-to-some-openapi-file.json" @@ -67,7 +67,7 @@ } }, "messages": { - "UserSignedUp": { + "OpenAPI-UserSignedUp": { "payload": { "schemaFormat": "application/vnd.oai.openapi;version=3.0.0", "schema": { diff --git a/test/docs/3.0.0/streetlights-unknown.json b/test/docs/3.0.0/streetlights-unknown.json new file mode 100644 index 00000000..cca2c654 --- /dev/null +++ b/test/docs/3.0.0/streetlights-unknown.json @@ -0,0 +1,106 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Account Service", + "version": "1.0.0", + "description": "This service is in charge of processing user signups" + }, + "channels": { + "Unknown-UserSignedUpChannel": { + "address": "user/signedup/{test_param}", + "parameters": { + "test_param": { + "enum": [ + "test" + ], + "default": "test", + "description": "Just a test description", + "examples": [ + "test" + ], + "location": "$message.payload#", + "x-custom-extension": "test" + } + }, + "messages": { + "UserSignedUp": { + "$ref": "#/components/messages/Unknown-UserSignedUp" + } + } + } + }, + "operations": { + "Unknown-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/Unknown-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Unknown-PublishUserSignedUpDefaultBinding": { + "action": "send", + "channel": { + "$ref": "#/channels/Unknown-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + } + }, + "components": { + "messages": { + "Unknown-UserSignedUp": { + "payload": { + "schemaFormat": "unknown-schema-format", + "schema": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "description": "Name of the user" + }, + "email": { + "type": "string", + "format": "email", + "description": "Email of the user" + } + }, + "externalDocs": { + "url": "https://account-service/docs/UserSignedUp" + }, + "deprecated": false + } + } + }, + "Unknown-UserSignedUpV2": { + "payload": { + "$ref": "external-schema.json" + } + } + } + } +} \ No newline at end of file diff --git a/tools/bundler/index.js b/tools/bundler/index.js index 2975a20b..ca8f5067 100644 --- a/tools/bundler/index.js +++ b/tools/bundler/index.js @@ -176,7 +176,23 @@ function getDefinitionName(def) { } if (def.startsWith('http://asyncapi.com/bindings')) { const result = bindingsRegex.exec(def); - if (result) return `${result[1].replace('/', '-')}-${result[2]}-${result[3]}`; + if (result) { + /* + 4th element is for internal definitions like http://asyncapi.com/bindings/jms/0.0.1/server.json#/definitions/property + + When is empty, we can ignore it: + convert this: http://asyncapi.com/bindings/jms/0.0.1/server.json + to this: bindings-jms-0.0.1-server + Otherwise we MUST add it to not broke Json Schema validation: + convert this: http://asyncapi.com/bindings/jms/0.0.1/server.json#/definitions/property + to this: bindings-jms-0.0.1-server/definitions/property + */ + if (result[4] === '') { + return `${result[1].replace('/', '-')}-${result[2]}-${result[3]}`; + } + + return `${result[1].replace('/', '-')}-${result[2]}-${result[3]}/${result[4].replace('#/', '')}`; + } } if (def.startsWith('http://asyncapi.com/extensions')) { const result = extensionsRegex.exec(def);