├── .gitignore ├── NOTICE ├── src ├── index.ts ├── postman-collection.ts ├── first-version.ts ├── interfaces.ts └── convert.ts ├── .github └── workflows │ ├── scripts │ ├── README.md │ └── mailchimp │ │ ├── package.json │ │ └── index.js │ ├── update-maintainers-trigger.yaml │ ├── automerge-for-humans-remove-ready-to-merge-label-on-edit.yml │ ├── autoupdate.yml │ ├── bump.yml │ ├── automerge.yml │ ├── please-take-a-look-command.yml │ ├── transfer-issue.yml │ ├── lint-pr-title.yml │ ├── stale-issues-prs.yml │ ├── automerge-orphans.yml │ ├── add-good-first-issue-labels.yml │ ├── if-nodejs-pr-testing.yml │ ├── help-command.yml │ ├── issues-prs-notifications.yml │ ├── if-nodejs-version-bump.yml │ ├── automerge-for-humans-merging.yml │ └── welcome-first-time-contrib.yml ├── test ├── input │ ├── openapi │ │ ├── external_reference.yml │ │ ├── no-channel-operation.yml │ │ ├── components_and_security.yml │ │ ├── operation_and_parameter.yml │ │ └── callbacks_and_contents.yml │ ├── postman │ │ ├── header-authentication.yml │ │ └── basic-collection.yml │ ├── 2.6.0 │ │ ├── for-3.0.0-with-reference-parameter.yml │ │ ├── for-3.0.0-with-mixed-parameters.yml │ │ ├── for-3.0.0-with-custom-schema-format.yml │ │ ├── for-3.0.0-with-deep-local-references.yml │ │ ├── streetlights.yml │ │ └── for-3.0.0-with-servers-and-channels-components.yml │ ├── 1.0.0 │ │ └── streetlights.yml │ ├── 1.1.0 │ │ └── streetlights.yml │ ├── 1.2.0 │ │ ├── streetlights.yml │ │ └── gitter-streaming.yml │ ├── 2.0.0-rc1 │ │ └── streetlights.yml │ ├── 2.0.0 │ │ └── streetlights.yml │ ├── 2.1.0 │ │ └── streetlights.yml │ ├── 2.2.0 │ │ └── streetlights.yml │ ├── 2.3.0 │ │ └── streetlights.yml │ ├── 2.4.0 │ │ └── streetlights.yml │ ├── 2.5.0 │ │ └── streetlights.yml │ └── 2.0.0-rc2 │ │ └── streetlights.yml ├── helpers.ts ├── output │ ├── openapi-to-asyncapi │ │ ├── external_reference.yml │ │ ├── no-channel-parameter.yml │ │ └── components_and_security.yml │ ├── 3.0.0 │ │ ├── from-2.6.0-with-reference-parameter.yml │ │ ├── from-2.6.0-with-mixed-parameters.yml │ │ ├── from-2.6.0-with-custom-schema-format.yml │ │ └── from-2.6.0-with-deep-local-references.yml │ ├── postman-to-asyncapi │ │ ├── header-option-client.yml │ │ ├── header-authentication.yml │ │ └── basic-collection.yml │ ├── 2.0.0-rc1 │ │ ├── streetlights.yml │ │ └── gitter-streaming.yml │ ├── 2.0.0 │ │ └── streetlights.yml │ ├── 2.1.0 │ │ └── streetlights.yml │ ├── 2.2.0 │ │ └── streetlights.yml │ ├── 2.3.0 │ │ └── streetlights.yml │ ├── 2.4.0 │ │ └── streetlights.yml │ ├── 2.5.0 │ │ └── streetlights.yml │ ├── 2.6.0 │ │ └── streetlights.yml │ └── 2.0.0-rc2 │ │ ├── streetlights.yml │ │ └── gitter-streaming.yml ├── convert.spec.ts ├── postman_to_asyncapi.spec.ts ├── second-to-third-version.spec.ts ├── openapi-to-asyncapi.spec.ts └── utils.spec.ts ├── CODEOWNERS ├── tsconfig.json ├── .releaserc ├── jest.config.ts ├── package.json └── .all-contributorsrc /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | node_modules 3 | lib 4 | dist 5 | coverage 6 | 7 | .DS_Store -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2016-2025 AsyncAPI Initiative 2 | 3 | This product includes software developed at 4 | AsyncAPI Initiative (http://www.asyncapi.com/). -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export { convert, convertOpenAPI, convertPostman } from './convert'; 2 | 3 | export type { AsyncAPIDocument, AsyncAPIConvertVersion, OpenAPIConvertVersion, ConvertOptions } from './interfaces'; 4 | -------------------------------------------------------------------------------- /.github/workflows/scripts/README.md: -------------------------------------------------------------------------------- 1 | The entire `scripts` directory is centrally managed in [.github](https://github.com/asyncapi/.github/) repository. Any changes in this folder should be done in central repository. -------------------------------------------------------------------------------- /test/input/openapi/external_reference.yml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Test API 4 | version: 1.0.0 5 | paths: 6 | /test: 7 | get: 8 | responses: 9 | '200': 10 | description: Successful response 11 | content: 12 | application/json: 13 | schema: 14 | $ref: './external.json' -------------------------------------------------------------------------------- /.github/workflows/scripts/mailchimp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "schedule-email", 3 | "description": "This code is responsible for scheduling an email campaign. This file is centrally managed in https://github.com/asyncapi/.github/", 4 | "license": "Apache 2.0", 5 | "dependencies": { 6 | "@actions/core": "1.6.0", 7 | "@mailchimp/mailchimp_marketing": "3.0.74" 8 | } 9 | } -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This file provides an overview of code owners in this repository. 2 | 3 | # Each line is a file pattern followed by one or more owners. 4 | # The last matching pattern has the most precedence. 5 | # For more details, read the following article on GitHub: https://help.github.com/articles/about-codeowners/. 6 | 7 | # The default owners are automatically added as reviewers when you open a pull request unless different owners are specified in the file. 8 | * @fmvilas @magicmatatjahu @asyncapi-bot-eve @jonaslagoni 9 | 10 | -------------------------------------------------------------------------------- /src/postman-collection.ts: -------------------------------------------------------------------------------- 1 | import { transpile } from 'postman2openapi'; 2 | import { from_openapi_to_asyncapi } from './openapi'; 3 | import { ConvertPostmanFunction, PostmanToAsyncAPIOptions } from 'interfaces'; 4 | 5 | export const converters: Record = { 6 | '3.0.0': from_postman_to_asyncapi 7 | } 8 | 9 | function from_postman_to_asyncapi(postman: any ,options:PostmanToAsyncAPIOptions ={}) { 10 | const perspective = options.perspective; 11 | const openapi = transpile(postman); 12 | const asyncapi = from_openapi_to_asyncapi(openapi , {perspective:perspective}); 13 | return asyncapi; 14 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./lib", 4 | "baseUrl": "./src", 5 | "target": "es6", 6 | "lib": [ 7 | "esnext" 8 | ], 9 | "declaration": true, 10 | "allowJs": true, 11 | "skipLibCheck": true, 12 | "esModuleInterop": true, 13 | "allowSyntheticDefaultImports": true, 14 | "strict": true, 15 | "forceConsistentCasingInFileNames": true, 16 | "noFallthroughCasesInSwitch": true, 17 | "module": "CommonJS", 18 | "moduleResolution": "node", 19 | "resolveJsonModule": true, 20 | "isolatedModules": true, 21 | }, 22 | "include": [ 23 | "src" 24 | ] 25 | } -------------------------------------------------------------------------------- /test/helpers.ts: -------------------------------------------------------------------------------- 1 | /* 2 | It is a helper required for testing on windows. It can't be solved by editor configuration and the end line setting because expected result is converted during tests. 3 | We need to remove all line breaks from the string 4 | as well as all multiple spaces and trim the string. 5 | */ 6 | export function removeLineBreaks(str: string) { 7 | return str.replace(/\r?\n|\r/g, '').replace(/\s+/g, ' ').trim(); 8 | } 9 | 10 | export function assertResults(output: string, result: string){ 11 | try{ 12 | expect(removeLineBreaks(output)).toEqual(removeLineBreaks(result)); 13 | } catch(e) { 14 | throw e; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.releaserc: -------------------------------------------------------------------------------- 1 | --- 2 | branches: 3 | - master 4 | # by default release workflow reacts on push not only to master. 5 | #This is why out of the box sematic release is configured for all these branches 6 | - name: next-spec 7 | prerelease: true 8 | - name: next-major 9 | prerelease: true 10 | - name: next-major-spec 11 | prerelease: true 12 | - name: beta 13 | prerelease: true 14 | - name: alpha 15 | prerelease: true 16 | - name: next 17 | prerelease: true 18 | plugins: 19 | - - "@semantic-release/commit-analyzer" 20 | - preset: conventionalcommits 21 | - - "@semantic-release/release-notes-generator" 22 | - preset: conventionalcommits 23 | - "@semantic-release/npm" 24 | - "@semantic-release/github" 25 | -------------------------------------------------------------------------------- /test/input/postman/header-authentication.yml: -------------------------------------------------------------------------------- 1 | info: 2 | name: Headers and Authentication Test Collection 3 | schema: 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json' 4 | item: 5 | - name: GET Request with Headers and Authentication 6 | request: 7 | method: GET 8 | header: 9 | - key: Authorization 10 | value: Bearer your_token 11 | - key: Accept 12 | value: application/json 13 | url: 14 | raw: 'https://example.com/api/authenticated' 15 | protocol: https 16 | host: 17 | - example 18 | - com 19 | path: 20 | - api 21 | - authenticated 22 | response: [] 23 | -------------------------------------------------------------------------------- /test/input/2.6.0/for-3.0.0-with-reference-parameter.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.6.0 2 | 3 | info: 4 | title: AsyncAPI Sample App 5 | version: 1.0.1 6 | 7 | channels: 8 | 'lightingMeasured/{parameter}/{parameter2}': 9 | parameters: 10 | parameter: 11 | schema: 12 | $ref: '#/components/schemas/sentAt' 13 | parameter2: 14 | schema: 15 | pattern: test 16 | publish: 17 | operationId: lightMeasured 18 | message: 19 | payload: 20 | type: object 21 | properties: 22 | someProperty: 23 | type: string 24 | 25 | components: 26 | schemas: 27 | sentAt: 28 | type: string 29 | format: date-time 30 | description: Date and time when the message was sent. -------------------------------------------------------------------------------- /jest.config.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from '@jest/types'; 2 | 3 | const config: Config.InitialOptions = { 4 | coverageReporters: [ 5 | 'json-summary', 6 | 'lcov', 7 | 'text' 8 | ], 9 | preset: 'ts-jest', 10 | // The root of your source code, typically /src 11 | // `` is a token Jest substitutes 12 | roots: [''], 13 | 14 | // Test spec file resolution pattern 15 | // Matches parent folder `__tests__` and filename 16 | // should contain `test` or `spec`. 17 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$', 18 | // Module file extensions for importing 19 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], 20 | testTimeout: 10000, 21 | collectCoverageFrom: [ 22 | 'src/**' 23 | ], 24 | }; 25 | 26 | export default config; -------------------------------------------------------------------------------- /src/first-version.ts: -------------------------------------------------------------------------------- 1 | import type { AsyncAPIDocument, ConvertOptions, ConvertFunction } from './interfaces'; 2 | 3 | export const converters: Record = { 4 | '1.0.0': from__undefined__to__1_0_0, 5 | '1.1.0': from__1_0_0__to__1_1_0, 6 | '1.2.0': from__1_1_0__to__1_2_0, 7 | } 8 | 9 | function from__undefined__to__1_0_0(asyncapi: AsyncAPIDocument, _: ConvertOptions): AsyncAPIDocument { 10 | asyncapi.asyncapi = '1.0.0'; 11 | return asyncapi; 12 | } 13 | 14 | function from__1_0_0__to__1_1_0(asyncapi: AsyncAPIDocument, _: ConvertOptions): AsyncAPIDocument { 15 | asyncapi.asyncapi = '1.1.0'; 16 | return asyncapi; 17 | } 18 | 19 | function from__1_1_0__to__1_2_0(asyncapi: AsyncAPIDocument, _: ConvertOptions): AsyncAPIDocument { 20 | asyncapi.asyncapi = '1.2.0'; 21 | return asyncapi; 22 | } 23 | -------------------------------------------------------------------------------- /test/output/openapi-to-asyncapi/external_reference.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 3.0.0 2 | info: 3 | title: Test API 4 | version: 1.0.0 5 | channels: 6 | test: 7 | address: /test 8 | messages: 9 | gettestResponse200: 10 | name: gettestResponse200 11 | title: GET response 200 12 | contentType: application/json 13 | payload: 14 | schemaFormat: application/vnd.oai.openapi;version=3.0.0 15 | schema: 16 | $ref: ./external.json 17 | summary: Successful response 18 | operations: 19 | gettest: 20 | action: receive 21 | channel: 22 | $ref: '#/channels/test' 23 | bindings: 24 | http: 25 | method: GET 26 | reply: 27 | channel: 28 | $ref: '#/channels/test' 29 | messages: 30 | - $ref: '#/channels/test/messages/gettestResponse200' -------------------------------------------------------------------------------- /test/output/3.0.0/from-2.6.0-with-reference-parameter.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 3.0.0 2 | info: 3 | title: AsyncAPI Sample App 4 | version: 1.0.1 5 | channels: 6 | 'lightingMeasured/{parameter}/{parameter2}': 7 | address: 'lightingMeasured/{parameter}/{parameter2}' 8 | messages: 9 | lightMeasured.message: 10 | payload: 11 | type: object 12 | properties: 13 | someProperty: 14 | type: string 15 | parameters: 16 | parameter: {} 17 | parameter2: {} 18 | operations: 19 | lightMeasured: 20 | action: receive 21 | channel: 22 | $ref: '#/channels/lightingMeasured~1{parameter}~1{parameter2}' 23 | messages: 24 | - $ref: >- 25 | #/channels/lightingMeasured~1{parameter}~1{parameter2}/messages/lightMeasured.message 26 | components: 27 | schemas: 28 | sentAt: 29 | type: string 30 | format: date-time 31 | description: Date and time when the message was sent. 32 | -------------------------------------------------------------------------------- /test/output/postman-to-asyncapi/header-option-client.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 3.0.0 2 | info: 3 | title: Headers and Authentication Test Collection 4 | version: 1.0.0 5 | servers: 6 | example_com: 7 | host: example.com 8 | protocol: https 9 | channels: 10 | api_authenticated: 11 | address: /api/authenticated 12 | messages: 13 | getRequestWithHeadersAndAuthenticationResponse200: 14 | name: getRequestWithHeadersAndAuthenticationResponse200 15 | title: GET response 200 16 | summary: '' 17 | operations: 18 | getRequestWithHeadersAndAuthentication: 19 | action: send 20 | channel: 21 | $ref: '#/channels/api_authenticated' 22 | summary: GET Request with Headers and Authentication 23 | description: GET Request with Headers and Authentication 24 | bindings: 25 | http: 26 | method: GET 27 | reply: 28 | channel: 29 | $ref: '#/channels/api_authenticated' 30 | messages: 31 | - $ref: >- 32 | #/channels/api_authenticated/messages/getRequestWithHeadersAndAuthenticationResponse200 -------------------------------------------------------------------------------- /test/input/openapi/no-channel-operation.yml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Sample Pet Store App 4 | description: This is a sample server for a pet store. 5 | termsOfService: 'http://example.com/terms/' 6 | contact: 7 | name: API Support 8 | url: 'http://www.example.com/support' 9 | email: support@example.com 10 | license: 11 | name: Apache 2.0 12 | url: 'https://www.apache.org/licenses/LICENSE-2.0.html' 13 | version: 1.0.1 14 | 15 | servers: 16 | - url: 'https://{username}.gigantic-server.com:{port}/{basePath}' 17 | description: The production API server 18 | variables: 19 | username: 20 | default: demo 21 | description: this value is assigned by the service provider, in this example `gigantic-server.com` 22 | port: 23 | enum: 24 | - '8443' 25 | - '443' 26 | default: '8443' 27 | basePath: 28 | default: v2 29 | tags: 30 | name: pet 31 | description: Pets operations 32 | 33 | externalDocs: 34 | description: Find more info here 35 | url: 'https://example.com' 36 | -------------------------------------------------------------------------------- /test/input/postman/basic-collection.yml: -------------------------------------------------------------------------------- 1 | info: 2 | name: Sample Postman Collection 3 | schema: 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json' 4 | item: 5 | - name: Sample Request 6 | request: 7 | method: GET 8 | header: [] 9 | url: 10 | raw: 'https://jsonplaceholder.typicode.com/posts/1' 11 | protocol: https 12 | host: 13 | - jsonplaceholder 14 | - typicode 15 | - com 16 | path: 17 | - posts 18 | - '1' 19 | response: [] 20 | - name: Sample POST Request 21 | request: 22 | method: POST 23 | header: 24 | - key: Content-Type 25 | value: application/json 26 | body: 27 | mode: raw 28 | raw: '{ "title": "foo", "body": "bar", "userId": 1 }' 29 | url: 30 | raw: 'https://jsonplaceholder.typicode.com/posts' 31 | protocol: https 32 | host: 33 | - jsonplaceholder 34 | - typicode 35 | - com 36 | path: 37 | - posts 38 | response: [] 39 | -------------------------------------------------------------------------------- /test/output/postman-to-asyncapi/header-authentication.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 3.0.0 2 | info: 3 | title: Headers and Authentication Test Collection 4 | version: 1.0.0 5 | servers: 6 | example_com: 7 | host: example.com 8 | protocol: https 9 | channels: 10 | api_authenticated: 11 | address: /api/authenticated 12 | messages: 13 | getRequestWithHeadersAndAuthenticationResponse200: 14 | name: getRequestWithHeadersAndAuthenticationResponse200 15 | title: GET response 200 16 | summary: '' 17 | operations: 18 | getRequestWithHeadersAndAuthentication: 19 | action: receive 20 | channel: 21 | $ref: '#/channels/api_authenticated' 22 | summary: GET Request with Headers and Authentication 23 | description: GET Request with Headers and Authentication 24 | bindings: 25 | http: 26 | method: GET 27 | reply: 28 | channel: 29 | $ref: '#/channels/api_authenticated' 30 | messages: 31 | - $ref: >- 32 | #/channels/api_authenticated/messages/getRequestWithHeadersAndAuthenticationResponse200 -------------------------------------------------------------------------------- /test/output/openapi-to-asyncapi/no-channel-parameter.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 3.0.0 2 | info: 3 | title: Sample Pet Store App 4 | version: 1.0.1 5 | description: This is a sample server for a pet store. 6 | termsOfService: 'http://example.com/terms/' 7 | contact: 8 | name: API Support 9 | url: 'http://www.example.com/support' 10 | email: support@example.com 11 | license: 12 | name: Apache 2.0 13 | url: 'https://www.apache.org/licenses/LICENSE-2.0.html' 14 | tags: 15 | - name: pet 16 | description: Pets operations 17 | externalDocs: 18 | description: Find more info here 19 | url: 'https://example.com' 20 | servers: 21 | gigantic_server_com__port___basePath_: 22 | host: '{username}.gigantic-server.com:{port}' 23 | pathname: '/{basePath}' 24 | protocol: https 25 | description: The production API server 26 | variables: 27 | username: 28 | default: demo 29 | description: >- 30 | this value is assigned by the service provider, in this example 31 | `gigantic-server.com` 32 | port: 33 | enum: 34 | - '8443' 35 | - '443' 36 | default: '8443' 37 | basePath: 38 | default: v2 39 | -------------------------------------------------------------------------------- /test/convert.spec.ts: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | 4 | import { convert } from '../src/convert'; 5 | 6 | describe('convert()', () => { 7 | it('should not convert to lowest version', () => { 8 | expect(() => convert(`asyncapi: '2.1.0'`, '2.0.0')).toThrow('Cannot downgrade from 2.1.0 to 2.0.0.'); 9 | }); 10 | 11 | it('should not convert from non existing version', () => { 12 | expect(() => convert(`asyncapi: '2.0.0-rc3'`, '2.0.0')).toThrow('Cannot convert from 2.0.0-rc3 to 2.0.0.'); 13 | }); 14 | 15 | it('should not convert to this same version', () => { 16 | expect(() => convert(`asyncapi: '2.0.0'`, '2.0.0')).toThrow('Cannot convert to the same version.'); 17 | }); 18 | 19 | it('should convert from 2.0.0 to 2.1.0 (JSON case)', () => { 20 | const input = fs.readFileSync(path.resolve(__dirname, 'input', '2.0.0', 'streetlights.json'), 'utf8'); 21 | let output = fs.readFileSync(path.resolve(__dirname, 'output', '2.1.0', 'streetlights.json'), 'utf8'); 22 | let result = convert(input, '2.1.0'); 23 | 24 | output = JSON.stringify(JSON.parse(output)); 25 | result = JSON.stringify(JSON.parse(JSON.stringify(result))); 26 | expect(output).toEqual(result); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /.github/workflows/update-maintainers-trigger.yaml: -------------------------------------------------------------------------------- 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 | name: Trigger MAINTAINERS.yaml file update 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | paths: 10 | # Check all valid CODEOWNERS locations: 11 | # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-location 12 | - 'CODEOWNERS' 13 | - '.github/CODEOWNERS' 14 | - '.docs/CODEOWNERS' 15 | 16 | jobs: 17 | trigger-maintainers-update: 18 | name: Trigger updating MAINTAINERS.yaml because of CODEOWNERS change 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - name: Repository Dispatch 23 | uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # https://github.com/peter-evans/repository-dispatch/releases/tag/v3.0.0 24 | with: 25 | # The PAT with the 'public_repo' scope is required 26 | token: ${{ secrets.GH_TOKEN }} 27 | repository: ${{ github.repository_owner }}/community 28 | event-type: trigger-maintainers-update 29 | -------------------------------------------------------------------------------- /.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml: -------------------------------------------------------------------------------- 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 | # Defence from evil contributor that after adding `ready-to-merge` all suddenly makes evil commit or evil change in PR title 5 | # Label is removed once above action is detected 6 | name: Remove ready-to-merge label 7 | 8 | on: 9 | pull_request_target: 10 | types: 11 | - synchronize 12 | - edited 13 | 14 | jobs: 15 | remove-ready-label: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Remove label 19 | uses: actions/github-script@v7 20 | with: 21 | github-token: ${{ secrets.GH_TOKEN }} 22 | script: | 23 | const labelToRemove = 'ready-to-merge'; 24 | const labels = context.payload.pull_request.labels; 25 | const isLabelPresent = labels.some(label => label.name === labelToRemove) 26 | if(!isLabelPresent) return; 27 | github.rest.issues.removeLabel({ 28 | issue_number: context.issue.number, 29 | owner: context.repo.owner, 30 | repo: context.repo.repo, 31 | name: labelToRemove 32 | }) 33 | -------------------------------------------------------------------------------- /test/output/3.0.0/from-2.6.0-with-mixed-parameters.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 3.0.0 2 | channels: 3 | '{enum}/{default}/{description}/{examples}/{location}/{mixed}': 4 | address: '{enum}/{default}/{description}/{examples}/{location}/{mixed}' 5 | messages: 6 | lightMeasured.message: 7 | payload: 8 | type: string 9 | parameters: 10 | enum: 11 | $ref: '#/components/parameters/enum' 12 | default: 13 | $ref: '#/components/parameters/default' 14 | description: 15 | $ref: '#/components/parameters/description' 16 | examples: 17 | $ref: '#/components/parameters/examples' 18 | location: 19 | $ref: '#/components/parameters/location' 20 | mixed: 21 | $ref: '#/components/parameters/mixed' 22 | schemaRef: {} 23 | components: 24 | schemas: 25 | schemaParameter: 26 | type: string 27 | enum: ["test"] 28 | parameters: 29 | enum: 30 | enum: ["test"] 31 | default: 32 | default: "test" 33 | description: 34 | description: Just a test description 35 | examples: 36 | examples: ["test"] 37 | location: 38 | location: "$message.payload" 39 | mixed: 40 | enum: ["test"] 41 | default: "test" 42 | description: Just a test description 43 | examples: ["test"] 44 | location: "$message.payload" 45 | x-custom-extension: "test" -------------------------------------------------------------------------------- /.github/workflows/autoupdate.yml: -------------------------------------------------------------------------------- 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 workflow is designed to work with: 5 | # - autoapprove and automerge workflows for dependabot and asyncapibot. 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 | 8 | # It uses GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch. 9 | # Autoupdating to latest destination branch works only in the context of upstream repo and not forks 10 | 11 | name: autoupdate 12 | 13 | on: 14 | push: 15 | branches-ignore: 16 | - 'version-bump/**' 17 | - 'dependabot/**' 18 | - 'bot/**' 19 | - 'all-contributors/**' 20 | 21 | jobs: 22 | autoupdate-for-bot: 23 | if: startsWith(github.repository, 'asyncapi/') 24 | name: Autoupdate autoapproved PR created in the upstream 25 | runs-on: ubuntu-latest 26 | steps: 27 | - name: Autoupdating 28 | uses: docker://chinthakagodawita/autoupdate-action:v1 29 | env: 30 | GITHUB_TOKEN: '${{ secrets.GH_TOKEN_BOT_EVE }}' 31 | PR_FILTER: "labelled" 32 | PR_LABELS: "autoupdate" 33 | PR_READY_STATE: "ready_for_review" 34 | MERGE_CONFLICT_ACTION: "ignore" 35 | -------------------------------------------------------------------------------- /src/interfaces.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * PUBLIC TYPES 3 | */ 4 | export type AsyncAPIDocument = { asyncapi: string } & Record; 5 | export type OpenAPIDocument = { openapi: string } & Record; 6 | export type AsyncAPIConvertVersion = '1.1.0' | '1.2.0' | '2.0.0-rc1' | '2.0.0-rc2' | '2.0.0' | '2.1.0' | '2.2.0' | '2.3.0' | '2.4.0' | '2.5.0' | '2.6.0' | '3.0.0'; 7 | 8 | export type OpenAPIConvertVersion = '3.0.0'; 9 | export type ConvertV2ToV3Options = { 10 | idGenerator?: (data: { asyncapi: AsyncAPIDocument, kind: 'channel' | 'operation' | 'message', key: string | number | undefined, path: Array, object: any, parentId?: string }) => string, 11 | pointOfView?: 'application' | 'client', 12 | useChannelIdExtension?: boolean; 13 | convertServerComponents?: boolean; 14 | convertChannelComponents?: boolean; 15 | } 16 | 17 | export type OpenAPIToAsyncAPIOptions = { 18 | perspective?: 'client' | 'server'; 19 | }; 20 | export type ConvertOptions = { 21 | v2tov3?: ConvertV2ToV3Options; 22 | openAPIToAsyncAPI?: OpenAPIToAsyncAPIOptions; 23 | postmanToAsyncAPI?: PostmanToAsyncAPIOptions; 24 | } 25 | 26 | export type PostmanToAsyncAPIOptions = { 27 | perspective?: 'client' | 'server'; 28 | } 29 | 30 | /** 31 | * PRIVATE TYPES 32 | */ 33 | export type ConvertFunction = (asyncapi: AsyncAPIDocument, options: ConvertOptions) => AsyncAPIDocument; 34 | export type ConvertOpenAPIFunction = (openapi: OpenAPIDocument, options: OpenAPIToAsyncAPIOptions) => AsyncAPIDocument; 35 | export type ConvertPostmanFunction = (postman: any , options: PostmanToAsyncAPIOptions) => AsyncAPIDocument; 36 | -------------------------------------------------------------------------------- /test/postman_to_asyncapi.spec.ts: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | import { convertPostman } from '../src/convert'; 4 | import { assertResults } from './helpers'; 5 | 6 | describe("convert() - postman to asyncapi", () => { 7 | it("should convert the basic structure of postman collection to asyncapi", () => { 8 | const input = fs.readFileSync(path.resolve(__dirname, "input", "postman", "basic-collection.yml"), "utf8"); 9 | const output = fs.readFileSync(path.resolve(__dirname, "output", "postman-to-asyncapi", "basic-collection.yml"), "utf8"); 10 | const result = convertPostman(input, '3.0.0'); 11 | assertResults(output, result); 12 | }); 13 | 14 | it("should convert headers and authentication from postman collection to asyncapi", () => { 15 | const input = fs.readFileSync(path.resolve(__dirname, "input", "postman", "header-authentication.yml"), "utf8"); 16 | const output = fs.readFileSync(path.resolve(__dirname, "output", "postman-to-asyncapi", "header-authentication.yml"), "utf8"); 17 | const result = convertPostman(input, '3.0.0'); 18 | assertResults(output, result); 19 | }); 20 | it("should convert headers and authentication from postman collection to asyncapi with perspective option client", () => { 21 | const input = fs.readFileSync(path.resolve(__dirname, "input", "postman", "header-authentication.yml"), "utf8"); 22 | const output = fs.readFileSync(path.resolve(__dirname, "output", "postman-to-asyncapi", "header-option-client.yml"), "utf8"); 23 | const result = convertPostman(input, '3.0.0', { perspective: 'client' }); 24 | assertResults(output, result); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@asyncapi/converter", 3 | "version": "1.6.2", 4 | "description": "Convert AsyncAPI documents from older to newer versions.", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "scripts": { 8 | "build": "tsc", 9 | "test": "cross-env CI=true NODE_ENV=test jest --coverage", 10 | "lint": "echo 'no linter configured yet'", 11 | "generate:assets": "npm run generate:readme:toc", 12 | "generate:readme:toc": "markdown-toc -i README.md", 13 | "bump:version": "npm --no-git-tag-version --allow-same-version version $VERSION", 14 | "prepublishOnly": "npm run build" 15 | }, 16 | "keywords": [ 17 | "asyncapi", 18 | "upgrade", 19 | "version", 20 | "convert" 21 | ], 22 | "files": [ 23 | "/lib", 24 | "./README.md", 25 | "./LICENSE" 26 | ], 27 | "repository": { 28 | "type": "git", 29 | "url": "git+https://github.com/asyncapi/converter-js.git" 30 | }, 31 | "bugs": { 32 | "url": "https://github.com/asyncapi/converter-js/issues" 33 | }, 34 | "homepage": "https://github.com/asyncapi/converter-js#readme", 35 | "publishConfig": { 36 | "access": "public" 37 | }, 38 | "author": "Fran Mendez (fmvilas.com)", 39 | "license": "Apache-2.0", 40 | "dependencies": { 41 | "@asyncapi/parser": "^3.1.0", 42 | "js-yaml": "^3.14.1", 43 | "path": "^0.12.7", 44 | "postman2openapi": "^1.2.1" 45 | }, 46 | "devDependencies": { 47 | "@jest/types": "^27.5.1", 48 | "@types/jest": "^27.4.1", 49 | "@types/js-yaml": "^4.0.5", 50 | "cross-env": "^7.0.3", 51 | "jest": "^27.5.1", 52 | "markdown-toc": "^1.2.0", 53 | "ts-jest": "^27.1.3", 54 | "ts-node": "^10.7.0", 55 | "typescript": "^4.6.2" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /test/input/2.6.0/for-3.0.0-with-mixed-parameters.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.6.0 2 | channels: 3 | '{enum}/{default}/{description}/{examples}/{location}/{mixed}': 4 | publish: 5 | operationId: lightMeasured 6 | message: 7 | payload: 8 | type: string 9 | parameters: 10 | enum: 11 | $ref: '#/components/parameters/enum' 12 | default: 13 | $ref: '#/components/parameters/default' 14 | description: 15 | $ref: '#/components/parameters/description' 16 | examples: 17 | $ref: '#/components/parameters/examples' 18 | location: 19 | $ref: '#/components/parameters/location' 20 | mixed: 21 | $ref: '#/components/parameters/mixed' 22 | schemaRef: 23 | schema: 24 | $ref: '#/components/schemas/schemaParameter' 25 | components: 26 | schemas: 27 | schemaParameter: 28 | type: string 29 | enum: ["test"] 30 | parameters: 31 | enum: 32 | schema: 33 | type: string 34 | enum: ["test"] 35 | default: 36 | schema: 37 | type: string 38 | default: "test" 39 | description: 40 | description: Just a test description 41 | schema: 42 | description: Just a test description 2 43 | type: string 44 | examples: 45 | schema: 46 | type: string 47 | examples: ["test"] 48 | location: 49 | location: "$message.payload" 50 | schema: 51 | type: string 52 | mixed: 53 | location: "$message.payload" 54 | description: Just a test description 55 | schema: 56 | type: string 57 | enum: ["test"] 58 | default: "test" 59 | description: Just a test description 2 60 | examples: ["test"] 61 | x-custom-extension: "test" -------------------------------------------------------------------------------- /test/output/postman-to-asyncapi/basic-collection.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 3.0.0 2 | info: 3 | title: Sample Postman Collection 4 | version: 1.0.0 5 | servers: 6 | typicode_com: 7 | host: jsonplaceholder.typicode.com 8 | protocol: https 9 | channels: 10 | posts_1: 11 | address: /posts/1 12 | messages: 13 | sampleRequestResponse200: 14 | name: sampleRequestResponse200 15 | title: GET response 200 16 | summary: '' 17 | posts: 18 | address: /posts 19 | messages: 20 | samplePostRequestRequest: 21 | name: samplePostRequestRequest 22 | title: POST request 23 | contentType: application/json 24 | payload: 25 | schemaFormat: application/vnd.oai.openapi;version=3.0.0 26 | schema: 27 | type: object 28 | properties: 29 | body: 30 | type: string 31 | example: bar 32 | title: 33 | type: string 34 | example: foo 35 | userId: 36 | type: number 37 | example: 1 38 | samplePostRequestResponse200: 39 | name: samplePostRequestResponse200 40 | title: POST response 200 41 | summary: '' 42 | operations: 43 | sampleRequest: 44 | action: receive 45 | channel: 46 | $ref: '#/channels/posts_1' 47 | summary: Sample Request 48 | description: Sample Request 49 | bindings: 50 | http: 51 | method: GET 52 | reply: 53 | channel: 54 | $ref: '#/channels/posts_1' 55 | messages: 56 | - $ref: '#/channels/posts_1/messages/sampleRequestResponse200' 57 | samplePostRequest: 58 | action: receive 59 | channel: 60 | $ref: '#/channels/posts' 61 | summary: Sample POST Request 62 | description: Sample POST Request 63 | bindings: 64 | http: 65 | method: POST 66 | messages: 67 | - $ref: '#/channels/posts/messages/samplePostRequestRequest' 68 | reply: 69 | channel: 70 | $ref: '#/channels/posts' 71 | messages: 72 | - $ref: '#/channels/posts/messages/samplePostRequestResponse200' -------------------------------------------------------------------------------- /test/input/2.6.0/for-3.0.0-with-custom-schema-format.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.6.0 2 | id: 'urn:example:com:smartylighting:streetlights:server' 3 | 4 | info: 5 | title: AsyncAPI Sample App 6 | version: 1.0.1 7 | description: This is a sample app. 8 | termsOfService: https://asyncapi.com/terms/ 9 | contact: 10 | name: API Support 11 | url: https://www.asyncapi.com/support 12 | email: support@asyncapi.org 13 | license: 14 | name: Apache 2.0 15 | url: https://www.apache.org/licenses/LICENSE-2.0.html 16 | 17 | tags: 18 | - name: e-commerce 19 | - name: another-tag 20 | description: Description... 21 | externalDocs: 22 | description: Find more info here 23 | url: https://www.asyncapi.com 24 | 25 | defaultContentType: application/json 26 | 27 | channels: 28 | 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured': 29 | parameters: 30 | streetlightId: 31 | $ref: '#/components/parameters/streetlightId' 32 | publish: 33 | operationId: lightMeasured 34 | message: 35 | schemaFormat: 'application/vnd.apache.avro;version=1.9.0' 36 | payload: # The following is an Avro schema in YAML format (JSON format is also supported) 37 | type: record 38 | name: User 39 | namespace: com.company 40 | doc: User information 41 | fields: 42 | - name: displayName 43 | type: string 44 | - name: email 45 | type: string 46 | - name: age 47 | type: int 48 | 49 | components: 50 | messages: 51 | lightMeasured: 52 | schemaFormat: 'application/vnd.apache.avro;version=1.9.0' 53 | payload: # The following is an Avro schema in YAML format (JSON format is also supported) 54 | type: record 55 | name: User 56 | namespace: com.company 57 | doc: User information 58 | fields: 59 | - name: displayName 60 | type: string 61 | - name: email 62 | type: string 63 | - name: age 64 | type: int 65 | 66 | parameters: 67 | streetlightId: 68 | description: The ID of the streetlight. 69 | schema: 70 | type: string -------------------------------------------------------------------------------- /.github/workflows/bump.yml: -------------------------------------------------------------------------------- 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 | # Purpose of this action is to update npm package in libraries that use it. It is like dependabot for asyncapi npm modules only. 5 | # 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 6 | 7 | name: Bump package version in dependent repos - if Node project 8 | 9 | on: 10 | # It cannot run on release event as when release is created then version is not yet bumped in package.json 11 | # This means we cannot extract easily latest version and have a risk that package is not yet on npm 12 | push: 13 | branches: 14 | - master 15 | 16 | jobs: 17 | bump-in-dependent-projects: 18 | name: Bump this package in repositories that depend on it 19 | if: startsWith(github.event.commits[0].message, 'chore(release):') 20 | runs-on: ubuntu-latest 21 | steps: 22 | - name: Checkout repo 23 | uses: actions/checkout@v4 24 | - name: Check if Node.js project and has package.json 25 | id: packagejson 26 | run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT 27 | - name: Setup corepack with pnpm and yarn 28 | if: steps.packagejson.outputs.exists == 'true' 29 | run: corepack enable 30 | - if: steps.packagejson.outputs.exists == 'true' 31 | name: Bumping latest version of this package in other repositories 32 | uses: derberg/npm-dependency-manager-for-your-github-org@f95b99236e8382a210042d8cfb84f42584e29c24 # using v6.2.0.-.- https://github.com/derberg/npm-dependency-manager-for-your-github-org/releases/tag/v6.2.0 33 | with: 34 | github_token: ${{ secrets.GH_TOKEN }} 35 | committer_username: asyncapi-bot 36 | committer_email: info@asyncapi.io 37 | repos_to_ignore: spec,bindings,saunter,server-api 38 | custom_id: "dependency update from asyncapi bot" 39 | search: "true" 40 | ignore_paths: .github/workflows 41 | -------------------------------------------------------------------------------- /.github/workflows/automerge.yml: -------------------------------------------------------------------------------- 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 | name: Automerge PRs from bots 5 | 6 | on: 7 | pull_request_target: 8 | types: 9 | - opened 10 | - synchronize 11 | 12 | jobs: 13 | autoapprove-for-bot: 14 | name: Autoapprove PR comming from a bot 15 | if: > 16 | contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]"]'), github.event.pull_request.user.login) && 17 | contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]"]'), github.actor) && 18 | !contains(github.event.pull_request.labels.*.name, 'released') 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Autoapproving 22 | uses: hmarr/auto-approve-action@44888193675f29a83e04faf4002fa8c0b537b1e4 # v3.2.1 is used https://github.com/hmarr/auto-approve-action/releases/tag/v3.2.1 23 | with: 24 | github-token: "${{ secrets.GH_TOKEN_BOT_EVE }}" 25 | 26 | - name: Label autoapproved 27 | uses: actions/github-script@v7 28 | with: 29 | github-token: ${{ secrets.GH_TOKEN }} 30 | script: | 31 | github.rest.issues.addLabels({ 32 | issue_number: context.issue.number, 33 | owner: context.repo.owner, 34 | repo: context.repo.repo, 35 | labels: ['autoapproved', 'autoupdate'] 36 | }) 37 | 38 | automerge-for-bot: 39 | name: Automerge PR autoapproved by a bot 40 | needs: [autoapprove-for-bot] 41 | runs-on: ubuntu-latest 42 | steps: 43 | - name: Automerging 44 | uses: pascalgn/automerge-action@22948e0bc22f0aa673800da838595a3e7347e584 #v0.15.6 https://github.com/pascalgn/automerge-action/releases/tag/v0.15.6 45 | env: 46 | GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" 47 | GITHUB_LOGIN: asyncapi-bot 48 | MERGE_LABELS: "!do-not-merge" 49 | MERGE_METHOD: "squash" 50 | MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})" 51 | MERGE_RETRIES: "20" 52 | MERGE_RETRY_SLEEP: "30000" 53 | -------------------------------------------------------------------------------- /test/second-to-third-version.spec.ts: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | 4 | import { convert } from '../src/convert'; 5 | import { assertResults } from './helpers'; 6 | 7 | describe('convert() - 2.X.X to 3.X.X versions', () => { 8 | it('should convert from 2.6.0 to 3.0.0', () => { 9 | const input = fs.readFileSync(path.resolve(__dirname, 'input', '2.6.0', 'for-3.0.0.yml'), 'utf8'); 10 | const output = fs.readFileSync(path.resolve(__dirname, 'output', '3.0.0', 'from-2.6.0.yml'), 'utf8'); 11 | const result = convert(input, '3.0.0'); 12 | assertResults(output, result); 13 | }); 14 | 15 | it('should convert from 2.6.0 to 3.0.0 (with used channel components)', () => { 16 | const input = fs.readFileSync(path.resolve(__dirname, 'input', '2.6.0', 'for-3.0.0-with-servers-and-channels-components.yml'), 'utf8'); 17 | const output = fs.readFileSync(path.resolve(__dirname, 'output', '3.0.0', 'from-2.6.0-with-servers-and-channels-components.yml'), 'utf8'); 18 | const result = convert(input, '3.0.0'); 19 | assertResults(output, result); 20 | }); 21 | 22 | it('should convert from 2.6.0 to 3.0.0 (with deep local references)', () => { 23 | const input = fs.readFileSync(path.resolve(__dirname, 'input', '2.6.0', 'for-3.0.0-with-deep-local-references.yml'), 'utf8'); 24 | const output = fs.readFileSync(path.resolve(__dirname, 'output', '3.0.0', 'from-2.6.0-with-deep-local-references.yml'), 'utf8'); 25 | const result = convert(input, '3.0.0'); 26 | assertResults(output, result); 27 | }); 28 | 29 | it('should convert from 2.6.0 to 3.0.0 (with custom schema formats)', () => { 30 | const input = fs.readFileSync(path.resolve(__dirname, 'input', '2.6.0', 'for-3.0.0-with-custom-schema-format.yml'), 'utf8'); 31 | const output = fs.readFileSync(path.resolve(__dirname, 'output', '3.0.0', 'from-2.6.0-with-custom-schema-format.yml'), 'utf8'); 32 | const result = convert(input, '3.0.0'); 33 | assertResults(output, result); 34 | }); 35 | 36 | it('should handle parameter object', () => { 37 | const input = fs.readFileSync(path.resolve(__dirname, 'input', '2.6.0', 'for-3.0.0-with-reference-parameter.yml'), 'utf8'); 38 | const output = fs.readFileSync(path.resolve(__dirname, 'output', '3.0.0', 'from-2.6.0-with-reference-parameter.yml'), 'utf8'); 39 | const result = convert(input, '3.0.0'); 40 | assertResults(output, result); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /test/input/2.6.0/for-3.0.0-with-deep-local-references.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.6.0 2 | 3 | info: 4 | title: AsyncAPI Sample App 5 | version: 1.0.1 6 | 7 | channels: 8 | 'lightingMeasured': 9 | publish: 10 | operationId: lightMeasured 11 | message: 12 | payload: 13 | type: object 14 | properties: 15 | someProperty: 16 | type: string 17 | circularProperty: 18 | $ref: '#/channels/lightingMeasured/publish/message/payload' 19 | 'turnOn': 20 | publish: 21 | message: 22 | $ref: '#/components/messages/turnOnOff' 23 | subscribe: 24 | message: 25 | oneOf: 26 | - $ref: '#/components/messages/turnOnOff' 27 | - messageId: customMessageId 28 | payload: 29 | type: object 30 | properties: 31 | someProperty: 32 | type: string 33 | circularProperty: 34 | $ref: '#/channels/turnOn/subscribe/message/oneOf/1/payload' 35 | 36 | components: 37 | channels: 38 | 'someChannel': 39 | publish: 40 | message: 41 | $ref: '#/components/messages/turnOnOff' 42 | subscribe: 43 | message: 44 | oneOf: 45 | - $ref: '#/components/messages/turnOnOff' 46 | - messageId: customMessageId 47 | payload: 48 | type: object 49 | properties: 50 | someProperty: 51 | type: string 52 | circularProperty: 53 | $ref: '#/components/channels/someChannel/subscribe/message/oneOf/1/payload' 54 | messages: 55 | turnOnOff: 56 | summary: Command a particular streetlight to turn the lights on or off. 57 | payload: 58 | $ref: '#/components/schemas/turnOnOffPayload' 59 | schemas: 60 | turnOnOffPayload: 61 | type: object 62 | properties: 63 | command: 64 | type: string 65 | enum: 66 | - 'on' 67 | - 'off' 68 | description: Whether to turn on or off the light. 69 | sentAt: 70 | $ref: '#/components/schemas/sentAt' 71 | sentAt: 72 | type: string 73 | format: date-time 74 | description: Date and time when the message was sent. 75 | parameters: 76 | streetlightId: 77 | description: The ID of the streetlight. 78 | schema: 79 | type: string -------------------------------------------------------------------------------- /.github/workflows/please-take-a-look-command.yml: -------------------------------------------------------------------------------- 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 | # It uses Github actions to listen for comments on issues and pull requests and 5 | # if the comment contains /please-take-a-look or /ptal it will add a comment pinging 6 | # the code-owners who are reviewers for PR 7 | 8 | name: Please take a Look 9 | 10 | on: 11 | issue_comment: 12 | types: [created] 13 | 14 | jobs: 15 | ping-for-attention: 16 | if: > 17 | github.event.issue.pull_request && 18 | github.event.issue.state != 'closed' && 19 | github.actor != 'asyncapi-bot' && 20 | ( 21 | contains(github.event.comment.body, '/please-take-a-look') || 22 | contains(github.event.comment.body, '/ptal') || 23 | contains(github.event.comment.body, '/PTAL') 24 | ) 25 | runs-on: ubuntu-latest 26 | steps: 27 | - name: Check for Please Take a Look Command 28 | uses: actions/github-script@v7 29 | with: 30 | github-token: ${{ secrets.GH_TOKEN }} 31 | script: | 32 | const prDetailsUrl = context.payload.issue.pull_request.url; 33 | const { data: pull } = await github.request(prDetailsUrl); 34 | const reviewers = pull.requested_reviewers.map(reviewer => reviewer.login); 35 | 36 | const { data: reviews } = await github.rest.pulls.listReviews({ 37 | owner: context.repo.owner, 38 | repo: context.repo.repo, 39 | pull_number: context.issue.number 40 | }); 41 | 42 | const reviewersWhoHaveReviewed = reviews.map(review => review.user.login); 43 | 44 | const reviewersWhoHaveNotReviewed = reviewers.filter(reviewer => !reviewersWhoHaveReviewed.includes(reviewer)); 45 | 46 | if (reviewersWhoHaveNotReviewed.length > 0) { 47 | const comment = reviewersWhoHaveNotReviewed.filter(reviewer => reviewer !== 'asyncapi-bot-eve' ).map(reviewer => `@${reviewer}`).join(' '); 48 | await github.rest.issues.createComment({ 49 | issue_number: context.issue.number, 50 | owner: context.repo.owner, 51 | repo: context.repo.repo, 52 | body: `${comment} Please take a look at this PR. Thanks! :wave:` 53 | }); 54 | } 55 | -------------------------------------------------------------------------------- /.github/workflows/transfer-issue.yml: -------------------------------------------------------------------------------- 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 | name: Transfer Issues between repositories 5 | 6 | on: 7 | issue_comment: 8 | types: 9 | - created 10 | 11 | permissions: 12 | issues: write 13 | 14 | jobs: 15 | transfer: 16 | if: ${{(!github.event.issue.pull_request && github.event.issue.state != 'closed' && github.actor != 'asyncapi-bot') && (startsWith(github.event.comment.body, '/transfer-issue') || startsWith(github.event.comment.body, '/ti'))}} 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout Repository 20 | uses: actions/checkout@v4 21 | - name: Extract Input 22 | id: extract_step 23 | env: 24 | COMMENT: "${{ github.event.comment.body }}" 25 | run: | 26 | REPO=$(echo "$COMMENT" | awk '{print $2}') 27 | echo "repo=$REPO" >> $GITHUB_OUTPUT 28 | - name: Check Repo 29 | uses: actions/github-script@v7 30 | with: 31 | github-token: ${{secrets.GH_TOKEN}} 32 | script: | 33 | const r = "${{github.repository}}" 34 | const [owner, repo] = r.split('/') 35 | const repoToMove = process.env.REPO_TO_MOVE 36 | const issue_number = context.issue.number 37 | try { 38 | const {data} = await github.rest.repos.get({ 39 | owner, 40 | repo: repoToMove 41 | }) 42 | }catch (e) { 43 | const body = `${repoToMove} is not a repo under ${owner}. You can only transfer issue to repos that belong to the same organization.` 44 | await github.rest.issues.createComment({ 45 | owner, 46 | repo, 47 | issue_number, 48 | body 49 | }) 50 | process.exit(1) 51 | } 52 | env: 53 | REPO_TO_MOVE: ${{steps.extract_step.outputs.repo}} 54 | - name: Transfer Issue 55 | id: transferIssue 56 | working-directory: ./ 57 | run: | 58 | gh issue transfer "$ISSUE_NUMBER" "asyncapi/$REPO_NAME" 59 | env: 60 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 61 | ISSUE_NUMBER: ${{ github.event.issue.number }} 62 | REPO_NAME: ${{ steps.extract_step.outputs.repo }} 63 | -------------------------------------------------------------------------------- /test/output/3.0.0/from-2.6.0-with-custom-schema-format.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 3.0.0 2 | id: 'urn:example:com:smartylighting:streetlights:server' 3 | info: 4 | title: AsyncAPI Sample App 5 | version: 1.0.1 6 | description: This is a sample app. 7 | termsOfService: 'https://asyncapi.com/terms/' 8 | contact: 9 | name: API Support 10 | url: 'https://www.asyncapi.com/support' 11 | email: support@asyncapi.org 12 | license: 13 | name: Apache 2.0 14 | url: 'https://www.apache.org/licenses/LICENSE-2.0.html' 15 | tags: 16 | - name: e-commerce 17 | - name: another-tag 18 | description: Description... 19 | externalDocs: 20 | description: Find more info here 21 | url: 'https://www.asyncapi.com' 22 | defaultContentType: application/json 23 | channels: 24 | 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured': 25 | address: 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured' 26 | messages: 27 | lightMeasured.message: 28 | payload: 29 | schemaFormat: application/vnd.apache.avro;version=1.9.0 30 | schema: 31 | type: record 32 | name: User 33 | namespace: com.company 34 | doc: User information 35 | fields: 36 | - name: displayName 37 | type: string 38 | - name: email 39 | type: string 40 | - name: age 41 | type: int 42 | parameters: 43 | streetlightId: 44 | $ref: '#/components/parameters/streetlightId' 45 | operations: 46 | lightMeasured: 47 | action: receive 48 | channel: 49 | $ref: >- 50 | #/channels/smartylighting~1streetlights~11~10~1event~1{streetlightId}~1lighting~1measured 51 | messages: 52 | - $ref: >- 53 | #/channels/smartylighting~1streetlights~11~10~1event~1{streetlightId}~1lighting~1measured/messages/lightMeasured.message 54 | components: 55 | messages: 56 | lightMeasured: 57 | payload: 58 | schemaFormat: application/vnd.apache.avro;version=1.9.0 59 | schema: 60 | type: record 61 | name: User 62 | namespace: com.company 63 | doc: User information 64 | fields: 65 | - name: displayName 66 | type: string 67 | - name: email 68 | type: string 69 | - name: age 70 | type: int 71 | parameters: 72 | streetlightId: 73 | description: The ID of the streetlight. -------------------------------------------------------------------------------- /test/openapi-to-asyncapi.spec.ts: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import path from 'path'; 3 | 4 | import { convertOpenAPI } from '../src/convert'; 5 | import { assertResults } from './helpers'; 6 | import { OpenAPIToAsyncAPIOptions } from '../src/interfaces' 7 | 8 | describe("convert() - openapi to asyncapi", () => { 9 | it("should convert the basic structure of openapi to asyncapi", () => { 10 | const input = fs.readFileSync(path.resolve(__dirname, "input", "openapi", "no-channel-operation.yml"), "utf8"); 11 | const output = fs.readFileSync(path.resolve(__dirname, "output", "openapi-to-asyncapi", "no-channel-parameter.yml"), "utf8"); 12 | const result = convertOpenAPI(input, '3.0.0'); 13 | assertResults(output, result); 14 | }); 15 | it("should convert the openapi operation and parameter keywoards to asyncapi", () => { 16 | const input = fs.readFileSync(path.resolve(__dirname, "input", "openapi", "operation_and_parameter.yml"), "utf8"); 17 | const output = fs.readFileSync(path.resolve(__dirname, "output", "openapi-to-asyncapi", "operation_and_parameter.yml"), "utf8"); 18 | const result = convertOpenAPI(input, '3.0.0'); 19 | assertResults(output, result); 20 | }); 21 | it("should convert the openapi components and securitySchemes keywoards to asyncapi", () => { 22 | const input = fs.readFileSync(path.resolve(__dirname, "input", "openapi", "components_and_security.yml"), "utf8"); 23 | const output = fs.readFileSync(path.resolve(__dirname, "output", "openapi-to-asyncapi", "components_and_security.yml"), "utf8"); 24 | const result = convertOpenAPI(input, '3.0.0'); 25 | assertResults(output, result); 26 | }); 27 | it("should convert the openapi contents and callbacks keywoards to asyncapi", () => { 28 | const input = fs.readFileSync(path.resolve(__dirname, "input", "openapi", "callbacks_and_contents.yml"), "utf8"); 29 | const output = fs.readFileSync(path.resolve(__dirname, "output", "openapi-to-asyncapi", "callbacks_and_contents.yml"), "utf8"); 30 | const result = convertOpenAPI(input, '3.0.0'); 31 | assertResults(output, result); 32 | }); 33 | it("should convert with 'client' perspective", () => { 34 | const input = fs.readFileSync(path.resolve(__dirname, "input", "openapi", "operation_and_parameter.yml"), "utf8"); 35 | const output = fs.readFileSync(path.resolve(__dirname, "output", "openapi-to-asyncapi", "operation_and_parameter_client.yml"), "utf8"); 36 | const options: OpenAPIToAsyncAPIOptions = { perspective: 'client' }; 37 | const result = convertOpenAPI(input, '3.0.0', options); 38 | assertResults(output, result); 39 | }); 40 | }); -------------------------------------------------------------------------------- /test/input/openapi/components_and_security.yml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Components and Security API 4 | version: 1.0.0 5 | description: An API showcasing various components and security schemes 6 | servers: 7 | - url: https://api.example.com/v1 8 | paths: 9 | /secure: 10 | get: 11 | summary: Secure endpoint 12 | security: 13 | - bearerAuth: [] 14 | responses: 15 | '200': 16 | description: Successful response 17 | content: 18 | application/json: 19 | schema: 20 | $ref: '#/components/schemas/SecureResponse' 21 | /oauth: 22 | get: 23 | summary: OAuth protected endpoint 24 | security: 25 | - oAuth2: 26 | - read 27 | - write 28 | responses: 29 | '200': 30 | description: Successful response 31 | content: 32 | application/json: 33 | schema: 34 | $ref: '#/components/schemas/OAuthResponse' 35 | components: 36 | schemas: 37 | SecureResponse: 38 | type: object 39 | properties: 40 | message: 41 | type: string 42 | OAuthResponse: 43 | type: object 44 | properties: 45 | data: 46 | type: string 47 | Error: 48 | type: object 49 | properties: 50 | code: 51 | type: integer 52 | message: 53 | type: string 54 | securitySchemes: 55 | bearerAuth: 56 | type: http 57 | scheme: bearer 58 | oAuth2: 59 | type: oauth2 60 | flows: 61 | authorizationCode: 62 | authorizationUrl: https://example.com/oauth/authorize 63 | tokenUrl: https://example.com/oauth/token 64 | scopes: 65 | read: Read access 66 | write: Write access 67 | parameters: 68 | limitParam: 69 | in: query 70 | name: limit 71 | schema: 72 | type: integer 73 | required: false 74 | description: Maximum number of items to return 75 | responses: 76 | NotFound: 77 | description: Resource not found 78 | content: 79 | application/json: 80 | schema: 81 | $ref: '#/components/schemas/Error' 82 | requestBodies: 83 | ItemInput: 84 | content: 85 | application/json: 86 | schema: 87 | type: object 88 | properties: 89 | name: 90 | type: string 91 | description: 92 | type: string 93 | headers: 94 | X-Rate-Limit: 95 | schema: 96 | type: integer 97 | description: Calls per hour allowed by the user -------------------------------------------------------------------------------- /.github/workflows/lint-pr-title.yml: -------------------------------------------------------------------------------- 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 | name: Lint PR title 5 | 6 | on: 7 | pull_request_target: 8 | types: [opened, reopened, synchronize, edited, ready_for_review] 9 | 10 | jobs: 11 | lint-pr-title: 12 | name: Lint PR title 13 | runs-on: ubuntu-latest 14 | steps: 15 | # Since this workflow is REQUIRED for a PR to be mergable, we have to have this 'if' statement in step level instead of job level. 16 | - if: ${{ !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors[bot]"]'), github.actor) }} 17 | uses: amannn/action-semantic-pull-request@c3cd5d1ea3580753008872425915e343e351ab54 #version 5.2.0 https://github.com/amannn/action-semantic-pull-request/releases/tag/v5.2.0 18 | id: lint_pr_title 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN}} 21 | with: 22 | subjectPattern: ^(?![A-Z]).+$ 23 | subjectPatternError: | 24 | The subject "{subject}" found in the pull request title "{title}" should start with a lowercase character. 25 | 26 | # Comments the error message from the above lint_pr_title action 27 | - if: ${{ always() && steps.lint_pr_title.outputs.error_message != null && !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors[bot]"]'), github.actor)}} 28 | name: Comment on PR 29 | uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd #use 2.5.0 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.5.0 30 | with: 31 | header: pr-title-lint-error 32 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN}} 33 | message: | 34 | 35 | We require all PRs to follow [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). 36 | More details 👇🏼 37 | ``` 38 | ${{ steps.lint_pr_title.outputs.error_message}} 39 | ``` 40 | # deletes the error comment if the title is correct 41 | - if: ${{ steps.lint_pr_title.outputs.error_message == null }} 42 | name: delete the comment 43 | uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd #use 2.5.0 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.5.0 44 | with: 45 | header: pr-title-lint-error 46 | delete: true 47 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN}} 48 | -------------------------------------------------------------------------------- /.github/workflows/stale-issues-prs.yml: -------------------------------------------------------------------------------- 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 | name: Manage stale issues and PRs 5 | 6 | on: 7 | schedule: 8 | - cron: "0 0 * * *" 9 | 10 | jobs: 11 | stale: 12 | if: startsWith(github.repository, 'asyncapi/') 13 | name: Mark issue or PR as stale 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 #v9.1.0 but pointing to commit for security reasons 17 | with: 18 | repo-token: ${{ secrets.GITHUB_TOKEN }} 19 | stale-issue-message: | 20 | This issue has been automatically marked as stale because it has not had recent activity :sleeping: 21 | 22 | It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. 23 | 24 | There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under [open governance model](https://github.com/asyncapi/community/blob/master/CHARTER.md). 25 | 26 | Let us figure out together how to push this issue forward. Connect with us through [one of many communication channels](https://github.com/asyncapi/community/issues/1) we established here. 27 | 28 | Thank you for your patience :heart: 29 | stale-pr-message: | 30 | This pull request has been automatically marked as stale because it has not had recent activity :sleeping: 31 | 32 | It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation. 33 | 34 | There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under [open governance model](https://github.com/asyncapi/community/blob/master/CHARTER.md). 35 | 36 | Let us figure out together how to push this pull request forward. Connect with us through [one of many communication channels](https://github.com/asyncapi/community/issues/1) we established here. 37 | 38 | Thank you for your patience :heart: 39 | days-before-stale: 120 40 | days-before-close: 120 41 | stale-issue-label: stale 42 | stale-pr-label: stale 43 | exempt-issue-labels: keep-open 44 | exempt-pr-labels: keep-open 45 | close-issue-reason: not_planned 46 | -------------------------------------------------------------------------------- /.github/workflows/scripts/mailchimp/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This code is centrally managed in https://github.com/asyncapi/.github/ 3 | * 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 4 | */ 5 | const mailchimp = require('@mailchimp/mailchimp_marketing'); 6 | const core = require('@actions/core'); 7 | const htmlContent = require('./htmlContent.js'); 8 | 9 | /** 10 | * Sending API request to mailchimp to schedule email to subscribers 11 | * Input is the URL to issue/discussion or other resource 12 | */ 13 | module.exports = async (link, title) => { 14 | 15 | let newCampaign; 16 | 17 | mailchimp.setConfig({ 18 | apiKey: process.env.MAILCHIMP_API_KEY, 19 | server: 'us12' 20 | }); 21 | 22 | /* 23 | * First we create campaign 24 | */ 25 | try { 26 | newCampaign = await mailchimp.campaigns.create({ 27 | type: 'regular', 28 | recipients: { 29 | list_id: '6e3e437abe', 30 | segment_opts: { 31 | match: 'any', 32 | conditions: [{ 33 | condition_type: 'Interests', 34 | field: 'interests-2801e38b9f', 35 | op: 'interestcontains', 36 | value: ['f7204f9b90'] 37 | }] 38 | } 39 | }, 40 | settings: { 41 | subject_line: `TSC attention required: ${ title }`, 42 | preview_text: 'Check out the latest topic that TSC members have to be aware of', 43 | title: `New topic info - ${ new Date(Date.now()).toUTCString()}`, 44 | from_name: 'AsyncAPI Initiative', 45 | reply_to: 'info@asyncapi.io', 46 | } 47 | }); 48 | } catch (error) { 49 | return core.setFailed(`Failed creating campaign: ${ JSON.stringify(error) }`); 50 | } 51 | 52 | /* 53 | * Content of the email is added separately after campaign creation 54 | */ 55 | try { 56 | await mailchimp.campaigns.setContent(newCampaign.id, { html: htmlContent(link, title) }); 57 | } catch (error) { 58 | return core.setFailed(`Failed adding content to campaign: ${ JSON.stringify(error) }`); 59 | } 60 | 61 | /* 62 | * We schedule an email to send it immediately 63 | */ 64 | try { 65 | //schedule for next hour 66 | //so if this code was created by new issue creation at 9:46, the email is scheduled for 10:00 67 | //is it like this as schedule has limitiations and you cannot schedule email for 9:48 68 | const scheduleDate = new Date(Date.parse(new Date(Date.now()).toISOString()) + 1 * 1 * 60 * 60 * 1000); 69 | scheduleDate.setUTCMinutes(00); 70 | 71 | await mailchimp.campaigns.schedule(newCampaign.id, { 72 | schedule_time: scheduleDate.toISOString(), 73 | }); 74 | } catch (error) { 75 | return core.setFailed(`Failed scheduling email: ${ JSON.stringify(error) }`); 76 | } 77 | 78 | core.info(`New email campaign created`); 79 | } -------------------------------------------------------------------------------- /.github/workflows/automerge-orphans.yml: -------------------------------------------------------------------------------- 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 | name: 'Notify on failing automerge' 5 | 6 | on: 7 | schedule: 8 | - cron: "0 0 * * *" 9 | 10 | jobs: 11 | identify-orphans: 12 | if: startsWith(github.repository, 'asyncapi/') 13 | name: Find orphans and notify 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v4 18 | - name: Get list of orphans 19 | uses: actions/github-script@v7 20 | id: orphans 21 | with: 22 | github-token: ${{ secrets.GITHUB_TOKEN }} 23 | script: | 24 | const query = `query($owner:String!, $name:String!) { 25 | repository(owner:$owner, name:$name){ 26 | pullRequests(first: 100, states: OPEN){ 27 | nodes{ 28 | title 29 | url 30 | author { 31 | resourcePath 32 | } 33 | } 34 | } 35 | } 36 | }`; 37 | const variables = { 38 | owner: context.repo.owner, 39 | name: context.repo.repo 40 | }; 41 | const { repository: { pullRequests: { nodes } } } = await github.graphql(query, variables); 42 | 43 | let orphans = nodes.filter( (pr) => pr.author.resourcePath === '/asyncapi-bot' || pr.author.resourcePath === '/apps/dependabot') 44 | 45 | if (orphans.length) { 46 | core.setOutput('found', 'true'); 47 | //Yes, this is very naive approach to assume there is just one PR causing issues, there can be a case that more PRs are affected the same day 48 | //The thing is that handling multiple PRs will increase a complexity in this PR that in my opinion we should avoid 49 | //The other PRs will be reported the next day the action runs, or person that checks first url will notice the other ones 50 | core.setOutput('url', orphans[0].url); 51 | core.setOutput('title', orphans[0].title); 52 | } 53 | - if: steps.orphans.outputs.found == 'true' 54 | name: Convert markdown to slack markdown 55 | # This workflow is from our own org repo and safe to reference by 'master'. 56 | uses: asyncapi/.github/.github/actions/slackify-markdown@master # //NOSONAR 57 | id: issuemarkdown 58 | with: 59 | markdown: "-> [${{steps.orphans.outputs.title}}](${{steps.orphans.outputs.url}})" 60 | - if: steps.orphans.outputs.found == 'true' 61 | name: Send info about orphan to slack 62 | uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # Using v2.3.2 63 | env: 64 | SLACK_WEBHOOK: ${{secrets.SLACK_CI_FAIL_NOTIFY}} 65 | SLACK_TITLE: 🚨 Not merged PR that should be automerged 🚨 66 | SLACK_MESSAGE: ${{steps.issuemarkdown.outputs.text}} 67 | MSG_MINIMAL: true -------------------------------------------------------------------------------- /.github/workflows/add-good-first-issue-labels.yml: -------------------------------------------------------------------------------- 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') && (contains(github.event.comment.body, '/good-first-issue') || contains(github.event.comment.body, '/gfi' ))}} 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Add label 18 | uses: actions/github-script@v7 19 | with: 20 | github-token: ${{ secrets.GH_TOKEN }} 21 | script: | 22 | const areas = ['javascript', 'typescript', 'java' , 'go', 'docs', 'ci-cd', 'design']; 23 | const words = context.payload.comment.body.trim().split(" "); 24 | const areaIndex = words.findIndex((word)=> word === '/gfi' || word === '/good-first-issue') + 1 25 | let area = words[areaIndex]; 26 | switch(area){ 27 | case 'ts': 28 | area = 'typescript'; 29 | break; 30 | case 'js': 31 | area = 'javascript'; 32 | break; 33 | case 'markdown': 34 | area = 'docs'; 35 | break; 36 | } 37 | if(!areas.includes(area)){ 38 | const message = `Hey @${context.payload.sender.login}, your message doesn't follow the requirements, you can try \`/help\`.` 39 | 40 | await github.rest.issues.createComment({ 41 | issue_number: context.issue.number, 42 | owner: context.repo.owner, 43 | repo: context.repo.repo, 44 | body: message 45 | }) 46 | } else { 47 | 48 | // remove area if there is any before adding new labels. 49 | const currentLabels = (await github.rest.issues.listLabelsOnIssue({ 50 | issue_number: context.issue.number, 51 | owner: context.repo.owner, 52 | repo: context.repo.repo, 53 | })).data.map(label => label.name); 54 | 55 | const shouldBeRemoved = currentLabels.filter(label => (label.startsWith('area/') && !label.endsWith(area))); 56 | shouldBeRemoved.forEach(label => { 57 | github.rest.issues.deleteLabel({ 58 | owner: context.repo.owner, 59 | repo: context.repo.repo, 60 | name: label, 61 | }); 62 | }); 63 | 64 | // Add new labels. 65 | github.rest.issues.addLabels({ 66 | issue_number: context.issue.number, 67 | owner: context.repo.owner, 68 | repo: context.repo.repo, 69 | labels: ['good first issue', `area/${area}`] 70 | }); 71 | } 72 | -------------------------------------------------------------------------------- /test/output/openapi-to-asyncapi/components_and_security.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 3.0.0 2 | info: 3 | title: Components and Security API 4 | version: 1.0.0 5 | description: An API showcasing various components and security schemes 6 | servers: 7 | example_com_v1: 8 | host: api.example.com 9 | pathname: /v1 10 | protocol: https 11 | channels: 12 | secure: 13 | address: /secure 14 | messages: 15 | getsecureResponse200: 16 | name: getsecureResponse200 17 | title: GET response 200 18 | contentType: application/json 19 | payload: 20 | $ref: '#/components/schemas/SecureResponse' 21 | summary: Successful response 22 | oauth: 23 | address: /oauth 24 | messages: 25 | getoauthResponse200: 26 | name: getoauthResponse200 27 | title: GET response 200 28 | contentType: application/json 29 | payload: 30 | $ref: '#/components/schemas/OAuthResponse' 31 | summary: Successful response 32 | operations: 33 | getsecure: 34 | action: receive 35 | channel: 36 | $ref: '#/channels/secure' 37 | summary: Secure endpoint 38 | bindings: 39 | http: 40 | method: GET 41 | reply: 42 | channel: 43 | $ref: '#/channels/secure' 44 | messages: 45 | - $ref: '#/channels/secure/messages/getsecureResponse200' 46 | getoauth: 47 | action: receive 48 | channel: 49 | $ref: '#/channels/oauth' 50 | summary: OAuth protected endpoint 51 | bindings: 52 | http: 53 | method: GET 54 | reply: 55 | channel: 56 | $ref: '#/channels/oauth' 57 | messages: 58 | - $ref: '#/channels/oauth/messages/getoauthResponse200' 59 | components: 60 | schemas: 61 | SecureResponse: 62 | schemaFormat: application/vnd.oai.openapi;version=3.0.0 63 | schema: 64 | type: object 65 | properties: 66 | message: 67 | type: string 68 | OAuthResponse: 69 | schemaFormat: application/vnd.oai.openapi;version=3.0.0 70 | schema: 71 | type: object 72 | properties: 73 | data: 74 | type: string 75 | Error: 76 | schemaFormat: application/vnd.oai.openapi;version=3.0.0 77 | schema: 78 | type: object 79 | properties: 80 | code: 81 | type: integer 82 | message: 83 | type: string 84 | securitySchemes: 85 | bearerAuth: 86 | type: http 87 | scheme: bearer 88 | oAuth2: 89 | type: oauth2 90 | flows: 91 | authorizationCode: 92 | authorizationUrl: 'https://example.com/oauth/authorize' 93 | tokenUrl: 'https://example.com/oauth/token' 94 | availableScopes: 95 | read: Read access 96 | write: Write access 97 | parameters: 98 | limitParam: 99 | description: Maximum number of items to return 100 | location: $message.header#/limit 101 | messages: 102 | NotFound: 103 | name: NotFound 104 | contentType: application/json 105 | payload: 106 | $ref: '#/components/schemas/Error' 107 | summary: Resource not found 108 | messageTraits: 109 | ItemInput: 110 | name: ItemInput 111 | contentType: application/json 112 | HeaderX-Rate-Limit: 113 | headers: 114 | type: object 115 | properties: 116 | X-Rate-Limit: 117 | type: integer 118 | required: 119 | - X-Rate-Limit -------------------------------------------------------------------------------- /test/input/openapi/operation_and_parameter.yml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Operations and Parameters API 4 | version: 1.0.0 5 | description: An API showcasing various operations and parameter types 6 | servers: 7 | - url: https://api.example.com/v1 8 | paths: 9 | /items: 10 | get: 11 | summary: List items 12 | operationId: listItems 13 | parameters: 14 | - in: query 15 | name: limit 16 | schema: 17 | type: integer 18 | required: false 19 | description: Maximum number of items to return 20 | - in: query 21 | name: offset 22 | schema: 23 | type: integer 24 | required: false 25 | description: Number of items to skip 26 | - in: header 27 | name: X-API-Key 28 | schema: 29 | type: string 30 | required: true 31 | description: API Key for authentication 32 | responses: 33 | '200': 34 | description: Successful response 35 | content: 36 | application/json: 37 | schema: 38 | type: array 39 | items: 40 | $ref: '#/components/schemas/Item' 41 | post: 42 | summary: Create an item 43 | operationId: createItem 44 | requestBody: 45 | required: true 46 | content: 47 | application/json: 48 | schema: 49 | $ref: '#/components/schemas/ItemInput' 50 | responses: 51 | '201': 52 | description: Created 53 | content: 54 | application/json: 55 | schema: 56 | $ref: '#/components/schemas/Item' 57 | /items/{itemId}: 58 | get: 59 | summary: Get an item 60 | operationId: getItem 61 | parameters: 62 | - in: path 63 | name: itemId 64 | required: true 65 | schema: 66 | type: string 67 | responses: 68 | '200': 69 | description: Successful response 70 | content: 71 | application/json: 72 | schema: 73 | $ref: '#/components/schemas/Item' 74 | put: 75 | summary: Update an item 76 | operationId: updateItem 77 | parameters: 78 | - in: path 79 | name: itemId 80 | required: true 81 | schema: 82 | type: string 83 | requestBody: 84 | required: true 85 | content: 86 | application/json: 87 | schema: 88 | $ref: '#/components/schemas/ItemInput' 89 | responses: 90 | '200': 91 | description: Successful response 92 | content: 93 | application/json: 94 | schema: 95 | $ref: '#/components/schemas/Item' 96 | delete: 97 | summary: Delete an item 98 | operationId: deleteItem 99 | parameters: 100 | - in: path 101 | name: itemId 102 | required: true 103 | schema: 104 | type: string 105 | responses: 106 | '204': 107 | description: Successful response 108 | components: 109 | schemas: 110 | Item: 111 | type: object 112 | properties: 113 | id: 114 | type: string 115 | name: 116 | type: string 117 | description: 118 | type: string 119 | ItemInput: 120 | type: object 121 | properties: 122 | name: 123 | type: string 124 | description: 125 | type: string -------------------------------------------------------------------------------- /test/output/3.0.0/from-2.6.0-with-deep-local-references.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 3.0.0 2 | info: 3 | title: AsyncAPI Sample App 4 | version: 1.0.1 5 | channels: 6 | lightingMeasured: 7 | address: lightingMeasured 8 | messages: 9 | lightMeasured.message: 10 | payload: 11 | type: object 12 | properties: 13 | someProperty: 14 | type: string 15 | circularProperty: 16 | $ref: >- 17 | #/channels/lightingMeasured/messages/lightMeasured.message/payload 18 | turnOn: 19 | address: turnOn 20 | messages: 21 | publish.message: 22 | $ref: '#/components/messages/turnOnOff' 23 | subscribe.message.0: 24 | $ref: '#/components/messages/turnOnOff' 25 | customMessageId: 26 | payload: 27 | type: object 28 | properties: 29 | someProperty: 30 | type: string 31 | circularProperty: 32 | $ref: '#/channels/turnOn/messages/customMessageId/payload' 33 | operations: 34 | lightMeasured: 35 | action: receive 36 | channel: 37 | $ref: '#/channels/lightingMeasured' 38 | messages: 39 | - $ref: '#/channels/lightingMeasured/messages/lightMeasured.message' 40 | turnOn.publish: 41 | action: receive 42 | channel: 43 | $ref: '#/channels/turnOn' 44 | messages: 45 | - $ref: '#/channels/turnOn/messages/publish.message' 46 | turnOn.subscribe: 47 | action: send 48 | channel: 49 | $ref: '#/channels/turnOn' 50 | messages: 51 | - $ref: '#/channels/turnOn/messages/subscribe.message.0' 52 | - $ref: '#/channels/turnOn/messages/customMessageId' 53 | components: 54 | channels: 55 | someChannel: 56 | address: someChannel 57 | messages: 58 | publish.message: 59 | $ref: '#/components/messages/turnOnOff' 60 | subscribe.message.0: 61 | $ref: '#/components/messages/turnOnOff' 62 | customMessageId: 63 | payload: 64 | type: object 65 | properties: 66 | someProperty: 67 | type: string 68 | circularProperty: 69 | $ref: >- 70 | #/components/channels/someChannel/messages/customMessageId/payload 71 | messages: 72 | turnOnOff: 73 | summary: Command a particular streetlight to turn the lights on or off. 74 | payload: 75 | $ref: '#/components/schemas/turnOnOffPayload' 76 | schemas: 77 | turnOnOffPayload: 78 | type: object 79 | properties: 80 | command: 81 | type: string 82 | enum: 83 | - 'on' 84 | - 'off' 85 | description: Whether to turn on or off the light. 86 | sentAt: 87 | $ref: '#/components/schemas/sentAt' 88 | sentAt: 89 | type: string 90 | format: date-time 91 | description: Date and time when the message was sent. 92 | parameters: 93 | streetlightId: 94 | description: The ID of the streetlight. 95 | operations: 96 | someChannel.publish: 97 | action: receive 98 | channel: 99 | $ref: '#/components/channels/someChannel' 100 | messages: 101 | - $ref: '#/components/channels/someChannel/messages/publish.message' 102 | someChannel.subscribe: 103 | action: send 104 | channel: 105 | $ref: '#/components/channels/someChannel' 106 | messages: 107 | - $ref: '#/components/channels/someChannel/messages/subscribe.message.0' 108 | - $ref: '#/components/channels/someChannel/messages/customMessageId' -------------------------------------------------------------------------------- /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "converter-js", 3 | "projectOwner": "asyncapi", 4 | "repoType": "github", 5 | "repoHost": "https://github.com", 6 | "files": [ 7 | "README.md" 8 | ], 9 | "imageSize": 100, 10 | "commit": false, 11 | "commitConvention": "none", 12 | "contributors": [ 13 | { 14 | "login": "magicmatatjahu", 15 | "name": "Maciej Urbańczyk", 16 | "avatar_url": "https://avatars.githubusercontent.com/u/20404945?v=4", 17 | "profile": "https://github.com/magicmatatjahu", 18 | "contributions": [ 19 | "maintenance", 20 | "code", 21 | "bug", 22 | "review", 23 | "test", 24 | "doc" 25 | ] 26 | }, 27 | { 28 | "login": "fmvilas", 29 | "name": "Fran Méndez", 30 | "avatar_url": "https://avatars.githubusercontent.com/u/242119?v=4", 31 | "profile": "http://www.fmvilas.com/", 32 | "contributions": [ 33 | "maintenance", 34 | "code", 35 | "bug", 36 | "review", 37 | "test", 38 | "doc" 39 | ] 40 | }, 41 | { 42 | "login": "derberg", 43 | "name": "Lukasz Gornicki", 44 | "avatar_url": "https://avatars.githubusercontent.com/u/6995927?v=4", 45 | "profile": "https://www.brainfart.dev/", 46 | "contributions": [ 47 | "maintenance", 48 | "code", 49 | "bug", 50 | "review", 51 | "test", 52 | "doc", 53 | "infra" 54 | ] 55 | }, 56 | { 57 | "login": "germanschnyder", 58 | "name": "Germán Schnyder", 59 | "avatar_url": "https://avatars.githubusercontent.com/u/1844525?v=4", 60 | "profile": "https://github.com/germanschnyder", 61 | "contributions": [ 62 | "code", 63 | "test" 64 | ] 65 | }, 66 | { 67 | "login": "bszwarc", 68 | "name": "Barbara Czyż", 69 | "avatar_url": "https://avatars.githubusercontent.com/u/17266942?v=4", 70 | "profile": "https://github.com/bszwarc", 71 | "contributions": [ 72 | "infra" 73 | ] 74 | }, 75 | { 76 | "login": "depimomo", 77 | "name": "depimomo", 78 | "avatar_url": "https://avatars.githubusercontent.com/u/12368942?v=4", 79 | "profile": "https://github.com/depimomo", 80 | "contributions": [ 81 | "code" 82 | ] 83 | }, 84 | { 85 | "login": "crypto-cmd", 86 | "name": "Orville Daley", 87 | "avatar_url": "https://avatars.githubusercontent.com/u/54287503?v=4", 88 | "profile": "https://github.com/crypto-cmd", 89 | "contributions": [ 90 | "code" 91 | ] 92 | }, 93 | { 94 | "login": "sundbry", 95 | "name": "Ryan R Sundberg", 96 | "avatar_url": "https://avatars.githubusercontent.com/u/549273?v=4", 97 | "profile": "https://www.arctype.co/", 98 | "contributions": [ 99 | "code" 100 | ] 101 | }, 102 | { 103 | "login": "ItshMoh", 104 | "name": "Mohan Kumar", 105 | "avatar_url": "https://avatars.githubusercontent.com/u/121867882?v=4", 106 | "profile": "https://github.com/ItshMoh", 107 | "contributions": [ 108 | "code", 109 | "test", 110 | "doc", 111 | "example" 112 | ] 113 | }, 114 | { 115 | "login": "Gmin2", 116 | "name": "Mintu Gogoi", 117 | "avatar_url": "https://avatars.githubusercontent.com/u/127925465?v=4", 118 | "profile": "https://github.com/Gmin2", 119 | "contributions": [ 120 | "code", 121 | "doc", 122 | "example", 123 | "test" 124 | ] 125 | } 126 | ], 127 | "contributorsPerLine": 7, 128 | "commitType": "docs" 129 | } 130 | -------------------------------------------------------------------------------- /test/input/1.0.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: '1.0.0' 2 | info: 3 | title: Streetlights API 4 | version: '1.0.0' 5 | description: | 6 | The Smartylighting Streetlights API allows you to remotely manage the city lights. 7 | 8 | ### Check out its awesome features: 9 | 10 | * Turn a specific streetlight on/off 🌃 11 | * Dim a specific streetlight 😎 12 | * Receive real-time information about environmental lighting conditions 📈 13 | license: 14 | name: Apache 2.0 15 | url: https://www.apache.org/licenses/LICENSE-2.0 16 | baseTopic: smartylighting.streetlights.1.0 17 | 18 | servers: 19 | - url: api.streetlights.smartylighting.com:{port} 20 | scheme: mqtt 21 | description: Test broker 22 | variables: 23 | port: 24 | description: Secure connection (TLS) is available through port 8883. 25 | default: '1883' 26 | enum: 27 | - '1883' 28 | - '8883' 29 | 30 | security: 31 | - apiKey: [] 32 | 33 | topics: 34 | event.{streetlightId}.lighting.measured: 35 | parameters: 36 | - $ref: '#/components/parameters/streetlightId' 37 | publish: 38 | $ref: '#/components/messages/lightMeasured' 39 | 40 | action.{streetlightId}.turn.on: 41 | parameters: 42 | - $ref: '#/components/parameters/streetlightId' 43 | subscribe: 44 | $ref: '#/components/messages/turnOnOff' 45 | 46 | action.{streetlightId}.turn.off: 47 | parameters: 48 | - $ref: '#/components/parameters/streetlightId' 49 | subscribe: 50 | $ref: '#/components/messages/turnOnOff' 51 | 52 | action.{streetlightId}.dim: 53 | parameters: 54 | - $ref: '#/components/parameters/streetlightId' 55 | subscribe: 56 | $ref: '#/components/messages/dimLight' 57 | 58 | components: 59 | messages: 60 | lightMeasured: 61 | summary: Inform about environmental lighting conditions for a particular streetlight. 62 | payload: 63 | $ref: "#/components/schemas/lightMeasuredPayload" 64 | turnOnOff: 65 | summary: Command a particular streetlight to turn the lights on or off. 66 | payload: 67 | $ref: "#/components/schemas/turnOnOffPayload" 68 | dimLight: 69 | summary: Command a particular streetlight to dim the lights. 70 | payload: 71 | $ref: "#/components/schemas/dimLightPayload" 72 | 73 | schemas: 74 | lightMeasuredPayload: 75 | type: object 76 | properties: 77 | lumens: 78 | type: integer 79 | minimum: 0 80 | description: Light intensity measured in lumens. 81 | sentAt: 82 | $ref: "#/components/schemas/sentAt" 83 | turnOnOffPayload: 84 | type: object 85 | properties: 86 | command: 87 | type: string 88 | enum: 89 | - on 90 | - off 91 | description: Whether to turn on or off the light. 92 | sentAt: 93 | $ref: "#/components/schemas/sentAt" 94 | dimLightPayload: 95 | type: object 96 | properties: 97 | percentage: 98 | type: integer 99 | description: Percentage to which the light should be dimmed to. 100 | minimum: 0 101 | maximum: 100 102 | sentAt: 103 | $ref: "#/components/schemas/sentAt" 104 | sentAt: 105 | type: string 106 | format: date-time 107 | description: Date and time when the message was sent. 108 | 109 | securitySchemes: 110 | apiKey: 111 | type: apiKey 112 | in: user 113 | description: Provide your API key as the user and leave the password empty. 114 | 115 | parameters: 116 | streetlightId: 117 | name: streetlightId 118 | description: The ID of the streetlight. 119 | schema: 120 | type: string 121 | -------------------------------------------------------------------------------- /test/input/1.1.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: '1.1.0' 2 | info: 3 | title: Streetlights API 4 | version: '1.0.0' 5 | description: | 6 | The Smartylighting Streetlights API allows you to remotely manage the city lights. 7 | 8 | ### Check out its awesome features: 9 | 10 | * Turn a specific streetlight on/off 🌃 11 | * Dim a specific streetlight 😎 12 | * Receive real-time information about environmental lighting conditions 📈 13 | license: 14 | name: Apache 2.0 15 | url: https://www.apache.org/licenses/LICENSE-2.0 16 | baseTopic: smartylighting.streetlights.1.0 17 | 18 | servers: 19 | - url: api.streetlights.smartylighting.com:{port} 20 | scheme: mqtt 21 | description: Test broker 22 | variables: 23 | port: 24 | description: Secure connection (TLS) is available through port 8883. 25 | default: '1883' 26 | enum: 27 | - '1883' 28 | - '8883' 29 | 30 | security: 31 | - apiKey: [] 32 | 33 | topics: 34 | event.{streetlightId}.lighting.measured: 35 | parameters: 36 | - $ref: '#/components/parameters/streetlightId' 37 | publish: 38 | $ref: '#/components/messages/lightMeasured' 39 | 40 | action.{streetlightId}.turn.on: 41 | parameters: 42 | - $ref: '#/components/parameters/streetlightId' 43 | subscribe: 44 | $ref: '#/components/messages/turnOnOff' 45 | 46 | action.{streetlightId}.turn.off: 47 | parameters: 48 | - $ref: '#/components/parameters/streetlightId' 49 | subscribe: 50 | $ref: '#/components/messages/turnOnOff' 51 | 52 | action.{streetlightId}.dim: 53 | parameters: 54 | - $ref: '#/components/parameters/streetlightId' 55 | subscribe: 56 | $ref: '#/components/messages/dimLight' 57 | 58 | components: 59 | messages: 60 | lightMeasured: 61 | summary: Inform about environmental lighting conditions for a particular streetlight. 62 | payload: 63 | $ref: "#/components/schemas/lightMeasuredPayload" 64 | turnOnOff: 65 | summary: Command a particular streetlight to turn the lights on or off. 66 | payload: 67 | $ref: "#/components/schemas/turnOnOffPayload" 68 | dimLight: 69 | summary: Command a particular streetlight to dim the lights. 70 | payload: 71 | $ref: "#/components/schemas/dimLightPayload" 72 | 73 | schemas: 74 | lightMeasuredPayload: 75 | type: object 76 | properties: 77 | lumens: 78 | type: integer 79 | minimum: 0 80 | description: Light intensity measured in lumens. 81 | sentAt: 82 | $ref: "#/components/schemas/sentAt" 83 | turnOnOffPayload: 84 | type: object 85 | properties: 86 | command: 87 | type: string 88 | enum: 89 | - on 90 | - off 91 | description: Whether to turn on or off the light. 92 | sentAt: 93 | $ref: "#/components/schemas/sentAt" 94 | dimLightPayload: 95 | type: object 96 | properties: 97 | percentage: 98 | type: integer 99 | description: Percentage to which the light should be dimmed to. 100 | minimum: 0 101 | maximum: 100 102 | sentAt: 103 | $ref: "#/components/schemas/sentAt" 104 | sentAt: 105 | type: string 106 | format: date-time 107 | description: Date and time when the message was sent. 108 | 109 | securitySchemes: 110 | apiKey: 111 | type: apiKey 112 | in: user 113 | description: Provide your API key as the user and leave the password empty. 114 | 115 | parameters: 116 | streetlightId: 117 | name: streetlightId 118 | description: The ID of the streetlight. 119 | schema: 120 | type: string 121 | -------------------------------------------------------------------------------- /test/input/1.2.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: '1.2.0' 2 | info: 3 | title: Streetlights API 4 | version: '1.0.0' 5 | description: | 6 | The Smartylighting Streetlights API allows you to remotely manage the city lights. 7 | 8 | ### Check out its awesome features: 9 | 10 | * Turn a specific streetlight on/off 🌃 11 | * Dim a specific streetlight 😎 12 | * Receive real-time information about environmental lighting conditions 📈 13 | license: 14 | name: Apache 2.0 15 | url: https://www.apache.org/licenses/LICENSE-2.0 16 | baseTopic: smartylighting.streetlights.1.0 17 | 18 | servers: 19 | - url: api.streetlights.smartylighting.com:{port} 20 | scheme: mqtt 21 | description: Test broker 22 | variables: 23 | port: 24 | description: Secure connection (TLS) is available through port 8883. 25 | default: '1883' 26 | enum: 27 | - '1883' 28 | - '8883' 29 | 30 | security: 31 | - apiKey: [] 32 | 33 | topics: 34 | event.{streetlightId}.lighting.measured: 35 | parameters: 36 | - $ref: '#/components/parameters/streetlightId' 37 | publish: 38 | $ref: '#/components/messages/lightMeasured' 39 | 40 | action.{streetlightId}.turn.on: 41 | parameters: 42 | - $ref: '#/components/parameters/streetlightId' 43 | subscribe: 44 | $ref: '#/components/messages/turnOnOff' 45 | 46 | action.{streetlightId}.turn.off: 47 | parameters: 48 | - $ref: '#/components/parameters/streetlightId' 49 | subscribe: 50 | $ref: '#/components/messages/turnOnOff' 51 | 52 | action.{streetlightId}.dim: 53 | parameters: 54 | - $ref: '#/components/parameters/streetlightId' 55 | subscribe: 56 | $ref: '#/components/messages/dimLight' 57 | 58 | components: 59 | messages: 60 | lightMeasured: 61 | summary: Inform about environmental lighting conditions for a particular streetlight. 62 | payload: 63 | $ref: "#/components/schemas/lightMeasuredPayload" 64 | turnOnOff: 65 | summary: Command a particular streetlight to turn the lights on or off. 66 | payload: 67 | $ref: "#/components/schemas/turnOnOffPayload" 68 | dimLight: 69 | summary: Command a particular streetlight to dim the lights. 70 | payload: 71 | $ref: "#/components/schemas/dimLightPayload" 72 | 73 | schemas: 74 | lightMeasuredPayload: 75 | type: object 76 | properties: 77 | lumens: 78 | type: integer 79 | minimum: 0 80 | description: Light intensity measured in lumens. 81 | sentAt: 82 | $ref: "#/components/schemas/sentAt" 83 | turnOnOffPayload: 84 | type: object 85 | properties: 86 | command: 87 | type: string 88 | enum: 89 | - on 90 | - off 91 | description: Whether to turn on or off the light. 92 | sentAt: 93 | $ref: "#/components/schemas/sentAt" 94 | dimLightPayload: 95 | type: object 96 | properties: 97 | percentage: 98 | type: integer 99 | description: Percentage to which the light should be dimmed to. 100 | minimum: 0 101 | maximum: 100 102 | sentAt: 103 | $ref: "#/components/schemas/sentAt" 104 | sentAt: 105 | type: string 106 | format: date-time 107 | description: Date and time when the message was sent. 108 | 109 | securitySchemes: 110 | apiKey: 111 | type: apiKey 112 | in: user 113 | description: Provide your API key as the user and leave the password empty. 114 | 115 | parameters: 116 | streetlightId: 117 | name: streetlightId 118 | description: The ID of the streetlight. 119 | schema: 120 | type: string 121 | -------------------------------------------------------------------------------- /.github/workflows/if-nodejs-pr-testing.yml: -------------------------------------------------------------------------------- 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 | # It does magic only if there is package.json file in the root of the project 5 | name: PR testing - if Node project 6 | 7 | on: 8 | pull_request: 9 | types: [opened, reopened, synchronize, ready_for_review] 10 | 11 | jobs: 12 | test-nodejs-pr: 13 | name: Test NodeJS PR - ${{ matrix.os }} 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | matrix: 17 | os: [ubuntu-latest, macos-latest, windows-latest] 18 | steps: 19 | - if: > 20 | !github.event.pull_request.draft && !( 21 | (github.actor == 'asyncapi-bot' && ( 22 | startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') || 23 | startsWith(github.event.pull_request.title, 'chore(release):') 24 | )) || 25 | (github.actor == 'asyncapi-bot-eve' && ( 26 | startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') || 27 | startsWith(github.event.pull_request.title, 'chore(release):') 28 | )) || 29 | (github.actor == 'allcontributors[bot]' && 30 | startsWith(github.event.pull_request.title, 'docs: add') 31 | ) 32 | ) 33 | id: should_run 34 | name: Should Run 35 | run: echo "shouldrun=true" >> $GITHUB_OUTPUT 36 | shell: bash 37 | - if: steps.should_run.outputs.shouldrun == 'true' 38 | name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows 39 | run: | 40 | git config --global core.autocrlf false 41 | git config --global core.eol lf 42 | shell: bash 43 | - if: steps.should_run.outputs.shouldrun == 'true' 44 | name: Checkout repository 45 | uses: actions/checkout@v4 46 | - if: steps.should_run.outputs.shouldrun == 'true' 47 | name: Check if Node.js project and has package.json 48 | id: packagejson 49 | run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT 50 | shell: bash 51 | - if: steps.packagejson.outputs.exists == 'true' 52 | name: Determine what node version to use 53 | # This workflow is from our own org repo and safe to reference by 'master'. 54 | uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master # //NOSONAR 55 | with: 56 | node-version: ${{ vars.NODE_VERSION }} 57 | id: lockversion 58 | - if: steps.packagejson.outputs.exists == 'true' 59 | name: Setup Node.js 60 | uses: actions/setup-node@v4 61 | with: 62 | node-version: "${{ steps.lockversion.outputs.version }}" 63 | - if: steps.lockversion.outputs.version == '18' && matrix.os == 'windows-latest' 64 | #npm cli 10 is buggy because of some cache issue 65 | name: Install npm cli 8 66 | shell: bash 67 | run: npm install -g npm@8.19.4 68 | - if: steps.packagejson.outputs.exists == 'true' 69 | name: Install dependencies 70 | shell: bash 71 | run: npm ci 72 | - if: steps.packagejson.outputs.exists == 'true' 73 | name: Test 74 | run: npm test --if-present 75 | - if: steps.packagejson.outputs.exists == 'true' && matrix.os == 'ubuntu-latest' 76 | #linting should run just one and not on all possible operating systems 77 | name: Run linter 78 | run: npm run lint --if-present 79 | - if: steps.packagejson.outputs.exists == 'true' 80 | name: Run release assets generation to make sure PR does not break it 81 | shell: bash 82 | run: npm run generate:assets --if-present 83 | -------------------------------------------------------------------------------- /test/input/2.0.0-rc1/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.0.0-rc1 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 | - url: 'api.streetlights.smartylighting.com:{port}' 11 | description: Test broker 12 | variables: 13 | port: 14 | description: Secure connection (TLS) is available through port 8883. 15 | default: '1883' 16 | enum: 17 | - '1883' 18 | - '8883' 19 | protocol: mqtt 20 | security: 21 | - apiKey: [] 22 | components: 23 | messages: 24 | lightMeasured: 25 | summary: >- 26 | Inform about environmental lighting conditions for a particular 27 | streetlight. 28 | payload: 29 | $ref: '#/components/schemas/lightMeasuredPayload' 30 | turnOnOff: 31 | summary: Command a particular streetlight to turn the lights on or off. 32 | payload: 33 | $ref: '#/components/schemas/turnOnOffPayload' 34 | dimLight: 35 | summary: Command a particular streetlight to dim the lights. 36 | payload: 37 | $ref: '#/components/schemas/dimLightPayload' 38 | schemas: 39 | lightMeasuredPayload: 40 | type: object 41 | properties: 42 | lumens: 43 | type: integer 44 | minimum: 0 45 | description: Light intensity measured in lumens. 46 | sentAt: 47 | $ref: '#/components/schemas/sentAt' 48 | turnOnOffPayload: 49 | type: object 50 | properties: 51 | command: 52 | type: string 53 | enum: 54 | - 'on' 55 | - 'off' 56 | description: Whether to turn on or off the light. 57 | sentAt: 58 | $ref: '#/components/schemas/sentAt' 59 | dimLightPayload: 60 | type: object 61 | properties: 62 | percentage: 63 | type: integer 64 | description: Percentage to which the light should be dimmed to. 65 | minimum: 0 66 | maximum: 100 67 | sentAt: 68 | $ref: '#/components/schemas/sentAt' 69 | sentAt: 70 | type: string 71 | format: date-time 72 | description: Date and time when the message was sent. 73 | securitySchemes: 74 | apiKey: 75 | type: apiKey 76 | in: user 77 | description: Provide your API key as the user and leave the password empty. 78 | parameters: 79 | streetlightId: 80 | name: 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 | - $ref: '#/components/parameters/streetlightId' 88 | publish: 89 | message: 90 | $ref: '#/components/messages/lightMeasured' 91 | 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on': 92 | parameters: 93 | - $ref: '#/components/parameters/streetlightId' 94 | subscribe: 95 | message: 96 | $ref: '#/components/messages/turnOnOff' 97 | 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/off': 98 | parameters: 99 | - $ref: '#/components/parameters/streetlightId' 100 | subscribe: 101 | message: 102 | $ref: '#/components/messages/turnOnOff' 103 | 'smartylighting/streetlights/1/0/action/{streetlightId}/dim': 104 | parameters: 105 | - $ref: '#/components/parameters/streetlightId' 106 | subscribe: 107 | message: 108 | $ref: '#/components/messages/dimLight' 109 | -------------------------------------------------------------------------------- /test/output/2.0.0-rc1/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.0.0-rc1 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 | - url: 'api.streetlights.smartylighting.com:{port}' 11 | description: Test broker 12 | variables: 13 | port: 14 | description: Secure connection (TLS) is available through port 8883. 15 | default: '1883' 16 | enum: 17 | - '1883' 18 | - '8883' 19 | protocol: mqtt 20 | security: 21 | - apiKey: [] 22 | components: 23 | messages: 24 | lightMeasured: 25 | summary: >- 26 | Inform about environmental lighting conditions for a particular 27 | streetlight. 28 | payload: 29 | $ref: '#/components/schemas/lightMeasuredPayload' 30 | turnOnOff: 31 | summary: Command a particular streetlight to turn the lights on or off. 32 | payload: 33 | $ref: '#/components/schemas/turnOnOffPayload' 34 | dimLight: 35 | summary: Command a particular streetlight to dim the lights. 36 | payload: 37 | $ref: '#/components/schemas/dimLightPayload' 38 | schemas: 39 | lightMeasuredPayload: 40 | type: object 41 | properties: 42 | lumens: 43 | type: integer 44 | minimum: 0 45 | description: Light intensity measured in lumens. 46 | sentAt: 47 | $ref: '#/components/schemas/sentAt' 48 | turnOnOffPayload: 49 | type: object 50 | properties: 51 | command: 52 | type: string 53 | enum: 54 | - 'on' 55 | - 'off' 56 | description: Whether to turn on or off the light. 57 | sentAt: 58 | $ref: '#/components/schemas/sentAt' 59 | dimLightPayload: 60 | type: object 61 | properties: 62 | percentage: 63 | type: integer 64 | description: Percentage to which the light should be dimmed to. 65 | minimum: 0 66 | maximum: 100 67 | sentAt: 68 | $ref: '#/components/schemas/sentAt' 69 | sentAt: 70 | type: string 71 | format: date-time 72 | description: Date and time when the message was sent. 73 | securitySchemes: 74 | apiKey: 75 | type: apiKey 76 | in: user 77 | description: Provide your API key as the user and leave the password empty. 78 | parameters: 79 | streetlightId: 80 | name: 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 | - $ref: '#/components/parameters/streetlightId' 88 | publish: 89 | message: 90 | $ref: '#/components/messages/lightMeasured' 91 | 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on': 92 | parameters: 93 | - $ref: '#/components/parameters/streetlightId' 94 | subscribe: 95 | message: 96 | $ref: '#/components/messages/turnOnOff' 97 | 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/off': 98 | parameters: 99 | - $ref: '#/components/parameters/streetlightId' 100 | subscribe: 101 | message: 102 | $ref: '#/components/messages/turnOnOff' 103 | 'smartylighting/streetlights/1/0/action/{streetlightId}/dim': 104 | parameters: 105 | - $ref: '#/components/parameters/streetlightId' 106 | subscribe: 107 | message: 108 | $ref: '#/components/messages/dimLight' 109 | -------------------------------------------------------------------------------- /.github/workflows/help-command.yml: -------------------------------------------------------------------------------- 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 | name: Create help comment 5 | 6 | on: 7 | issue_comment: 8 | types: 9 | - created 10 | 11 | jobs: 12 | create_help_comment_pr: 13 | if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '/help') && github.actor != 'asyncapi-bot' }} 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Add comment to PR 17 | uses: actions/github-script@v7 18 | env: 19 | ACTOR: ${{ github.actor }} 20 | with: 21 | github-token: ${{ secrets.GH_TOKEN }} 22 | script: | 23 | //Yes to add comment to PR the same endpoint is use that we use to create a comment in issue 24 | //For more details http://developer.github.com/v3/issues/comments/ 25 | //Also proved by this action https://github.com/actions-ecosystem/action-create-comment/blob/main/src/main.ts 26 | github.rest.issues.createComment({ 27 | issue_number: context.issue.number, 28 | owner: context.repo.owner, 29 | repo: context.repo.repo, 30 | body: `Hello, @${process.env.ACTOR}! 👋🏼 31 | 32 | I'm 🧞🧞🧞 Genie 🧞🧞🧞 from the magic lamp. Looks like somebody needs a hand! 33 | 34 | At the moment the following comments are supported in pull requests: 35 | 36 | - \`/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. 37 | - \`/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 38 | - \`/do-not-merge\` or \`/dnm\` - This comment will block automerging even if all conditions are met and ready-to-merge label is added 39 | - \`/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. (Currently only works for upstream branches.) 40 | - \`/update\` or \`/u\` - This comment will update the PR with the latest changes from the target branch. Unless there is a merge conflict or it is a draft PR. NOTE: this only updates the PR once, so if you need to update again, you need to call the command again.` 41 | }) 42 | 43 | create_help_comment_issue: 44 | if: ${{ !github.event.issue.pull_request && startsWith(github.event.comment.body, '/help') && github.actor != 'asyncapi-bot' }} 45 | runs-on: ubuntu-latest 46 | steps: 47 | - name: Add comment to Issue 48 | uses: actions/github-script@v7 49 | env: 50 | ACTOR: ${{ github.actor }} 51 | with: 52 | github-token: ${{ secrets.GH_TOKEN }} 53 | script: | 54 | github.rest.issues.createComment({ 55 | issue_number: context.issue.number, 56 | owner: context.repo.owner, 57 | repo: context.repo.repo, 58 | body: `Hello, @${process.env.ACTOR}! 👋🏼 59 | 60 | I'm 🧞🧞🧞 Genie 🧞🧞🧞 from the magic lamp. Looks like somebody needs a hand! 61 | 62 | At the moment the following comments are supported in issues: 63 | 64 | - \`/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\`. 65 | example: \`/gfi js\` or \`/good-first-issue ci-cd\` 66 | - \`/transfer-issue {repo-name}\` or \`/ti {repo-name}\` - transfer issue from the source repository to the other repository passed by the user. example: \`/ti cli\` or \`/transfer-issue cli\`.` 67 | }) -------------------------------------------------------------------------------- /test/input/2.0.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.0.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' 113 | -------------------------------------------------------------------------------- /test/input/2.1.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.1.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' 113 | -------------------------------------------------------------------------------- /test/input/2.2.0/streetlights.yml: -------------------------------------------------------------------------------- 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' 113 | -------------------------------------------------------------------------------- /test/input/2.3.0/streetlights.yml: -------------------------------------------------------------------------------- 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' 113 | -------------------------------------------------------------------------------- /test/input/2.4.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.4.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' 113 | -------------------------------------------------------------------------------- /test/input/2.5.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.5.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' 113 | -------------------------------------------------------------------------------- /test/input/2.6.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.6.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' 113 | -------------------------------------------------------------------------------- /test/output/2.0.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.0.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' 113 | -------------------------------------------------------------------------------- /test/output/2.1.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.1.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' 113 | -------------------------------------------------------------------------------- /test/output/2.2.0/streetlights.yml: -------------------------------------------------------------------------------- 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' 113 | -------------------------------------------------------------------------------- /test/output/2.3.0/streetlights.yml: -------------------------------------------------------------------------------- 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' 113 | -------------------------------------------------------------------------------- /test/output/2.4.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.4.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' 113 | -------------------------------------------------------------------------------- /test/output/2.5.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.5.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' 113 | -------------------------------------------------------------------------------- /test/output/2.6.0/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.6.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' 113 | -------------------------------------------------------------------------------- /test/input/2.0.0-rc2/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.0.0-rc2 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' 113 | -------------------------------------------------------------------------------- /test/output/2.0.0-rc2/streetlights.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.0.0-rc2 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' 113 | -------------------------------------------------------------------------------- /test/input/openapi/callbacks_and_contents.yml: -------------------------------------------------------------------------------- 1 | openapi: 3.0.0 2 | info: 3 | title: Callbacks, Links, and Content Types API 4 | version: 1.0.0 5 | description: An API showcasing callbacks, links, and various content types 6 | servers: 7 | - url: https://api.example.com/v1 8 | paths: 9 | /webhooks: 10 | post: 11 | summary: Subscribe to webhook 12 | operationId: subscribeWebhook 13 | requestBody: 14 | required: true 15 | content: 16 | application/json: 17 | schema: 18 | type: object 19 | properties: 20 | callbackUrl: 21 | type: string 22 | format: uri 23 | responses: 24 | '201': 25 | description: Subscription created 26 | callbacks: 27 | onEvent: 28 | '{$request.body#/callbackUrl}': 29 | post: 30 | requestBody: 31 | required: true 32 | content: 33 | application/json: 34 | schema: 35 | type: object 36 | properties: 37 | eventType: 38 | type: string 39 | eventData: 40 | type: object 41 | responses: 42 | '200': 43 | description: Webhook processed 44 | /users/{userId}: 45 | get: 46 | summary: Get a user 47 | operationId: getUser 48 | parameters: 49 | - in: path 50 | name: userId 51 | required: true 52 | schema: 53 | type: string 54 | responses: 55 | '200': 56 | description: Successful response 57 | content: 58 | application/json: 59 | schema: 60 | $ref: '#/components/schemas/User' 61 | links: 62 | userPosts: 63 | operationId: getUserPosts 64 | parameters: 65 | userId: '$response.body#/id' 66 | /users/{userId}/posts: 67 | get: 68 | summary: Get user posts 69 | operationId: getUserPosts 70 | parameters: 71 | - in: path 72 | name: userId 73 | required: true 74 | schema: 75 | type: string 76 | responses: 77 | '200': 78 | description: Successful response 79 | content: 80 | application/json: 81 | schema: 82 | type: array 83 | items: 84 | $ref: '#/components/schemas/Post' 85 | /upload: 86 | post: 87 | summary: Upload a file 88 | operationId: uploadFile 89 | requestBody: 90 | content: 91 | multipart/form-data: 92 | schema: 93 | type: object 94 | properties: 95 | file: 96 | type: string 97 | format: binary 98 | responses: 99 | '200': 100 | description: Successful upload 101 | content: 102 | application/json: 103 | schema: 104 | type: object 105 | properties: 106 | fileId: 107 | type: string 108 | /stream: 109 | get: 110 | summary: Get a data stream 111 | operationId: getStream 112 | responses: 113 | '200': 114 | description: Successful response 115 | content: 116 | application/octet-stream: 117 | schema: 118 | type: string 119 | format: binary 120 | components: 121 | schemas: 122 | User: 123 | type: object 124 | properties: 125 | id: 126 | type: string 127 | name: 128 | type: string 129 | Post: 130 | type: object 131 | properties: 132 | id: 133 | type: string 134 | title: 135 | type: string 136 | content: 137 | type: string -------------------------------------------------------------------------------- /.github/workflows/issues-prs-notifications.yml: -------------------------------------------------------------------------------- 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 6 | 7 | on: 8 | issues: 9 | types: [opened, reopened] 10 | 11 | pull_request_target: 12 | types: [opened, reopened, ready_for_review] 13 | 14 | discussion: 15 | types: [created] 16 | 17 | jobs: 18 | issue: 19 | if: github.event_name == 'issues' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' 20 | name: Notify slack on every new issue 21 | runs-on: ubuntu-latest 22 | steps: 23 | - name: Convert markdown to slack markdown for issue 24 | # This workflow is from our own org repo and safe to reference by 'master'. 25 | uses: asyncapi/.github/.github/actions/slackify-markdown@master # //NOSONAR 26 | id: issuemarkdown 27 | env: 28 | ISSUE_TITLE: ${{github.event.issue.title}} 29 | ISSUE_URL: ${{github.event.issue.html_url}} 30 | ISSUE_BODY: ${{github.event.issue.body}} 31 | with: 32 | markdown: "[${{ env.ISSUE_TITLE }}](${{ env.ISSUE_URL }}) \n ${{ env.ISSUE_BODY }}" 33 | - name: Send info about issue 34 | uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # Using v2.3.2 35 | env: 36 | SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}} 37 | SLACK_TITLE: 🐛 New Issue in ${{github.repository}} 🐛 38 | SLACK_MESSAGE: ${{steps.issuemarkdown.outputs.text}} 39 | MSG_MINIMAL: true 40 | 41 | pull_request: 42 | if: github.event_name == 'pull_request_target' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' 43 | name: Notify slack on every new pull request 44 | runs-on: ubuntu-latest 45 | steps: 46 | - name: Convert markdown to slack markdown for pull request 47 | # This workflow is from our own org repo and safe to reference by 'master'. 48 | uses: asyncapi/.github/.github/actions/slackify-markdown@master # //NOSONAR 49 | id: prmarkdown 50 | env: 51 | PR_TITLE: ${{github.event.pull_request.title}} 52 | PR_URL: ${{github.event.pull_request.html_url}} 53 | PR_BODY: ${{github.event.pull_request.body}} 54 | with: 55 | markdown: "[${{ env.PR_TITLE }}](${{ env.PR_URL }}) \n ${{ env.PR_BODY }}" 56 | - name: Send info about pull request 57 | uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # Using v2.3.2 58 | env: 59 | SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}} 60 | SLACK_TITLE: 💪 New Pull Request in ${{github.repository}} 💪 61 | SLACK_MESSAGE: ${{steps.prmarkdown.outputs.text}} 62 | MSG_MINIMAL: true 63 | 64 | discussion: 65 | if: github.event_name == 'discussion' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' 66 | name: Notify slack on every new pull request 67 | runs-on: ubuntu-latest 68 | steps: 69 | - name: Convert markdown to slack markdown for pull request 70 | # This workflow is from our own org repo and safe to reference by 'master'. 71 | uses: asyncapi/.github/.github/actions/slackify-markdown@master # //NOSONAR 72 | id: discussionmarkdown 73 | env: 74 | DISCUSSION_TITLE: ${{github.event.discussion.title}} 75 | DISCUSSION_URL: ${{github.event.discussion.html_url}} 76 | DISCUSSION_BODY: ${{github.event.discussion.body}} 77 | with: 78 | markdown: "[${{ env.DISCUSSION_TITLE }}](${{ env.DISCUSSION_URL }}) \n ${{ env.DISCUSSION_BODY }}" 79 | - name: Send info about pull request 80 | uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # Using v2.3.2 81 | env: 82 | SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}} 83 | SLACK_TITLE: 💬 New Discussion in ${{github.repository}} 💬 84 | SLACK_MESSAGE: ${{steps.discussionmarkdown.outputs.text}} 85 | MSG_MINIMAL: true 86 | -------------------------------------------------------------------------------- /.github/workflows/if-nodejs-version-bump.yml: -------------------------------------------------------------------------------- 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 | # It does magic only if there is package.json file in the root of the project 5 | name: Version bump - if Node.js project 6 | 7 | on: 8 | release: 9 | types: 10 | - published 11 | 12 | jobs: 13 | version_bump: 14 | name: Generate assets and bump NodeJS 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout repository 18 | uses: actions/checkout@v4 19 | with: 20 | # target branch of release. More info https://docs.github.com/en/rest/reference/repos#releases 21 | # in case release is created from release branch then we need to checkout from given branch 22 | # if @semantic-release/github is used to publish, the minimum version is 7.2.0 for proper working 23 | ref: ${{ github.event.release.target_commitish }} 24 | - name: Check if Node.js project and has package.json 25 | id: packagejson 26 | run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT 27 | - if: steps.packagejson.outputs.exists == 'true' 28 | name: Determine what node version to use 29 | # This workflow is from our own org repo and safe to reference by 'master'. 30 | uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master # //NOSONAR 31 | with: 32 | node-version: ${{ vars.NODE_VERSION }} 33 | id: lockversion 34 | - if: steps.packagejson.outputs.exists == 'true' 35 | name: Setup Node.js 36 | uses: actions/setup-node@v4 37 | with: 38 | node-version: "${{ steps.lockversion.outputs.version }}" 39 | cache: 'npm' 40 | cache-dependency-path: '**/package-lock.json' 41 | - if: steps.packagejson.outputs.exists == 'true' 42 | name: Install dependencies 43 | run: npm ci 44 | - if: steps.packagejson.outputs.exists == 'true' 45 | name: Assets generation 46 | run: npm run generate:assets --if-present 47 | - if: steps.packagejson.outputs.exists == 'true' 48 | name: Bump version in package.json 49 | # There is no need to substract "v" from the tag as version script handles it 50 | # When adding "bump:version" script in package.json, make sure no tags are added by default (--no-git-tag-version) as they are already added by release workflow 51 | # When adding "bump:version" script in package.json, make sure --allow-same-version is set in case someone forgot and updated package.json manually and we want to avoide this action to fail and raise confusion 52 | env: 53 | VERSION: ${{github.event.release.tag_name}} 54 | run: npm run bump:version 55 | - if: steps.packagejson.outputs.exists == 'true' 56 | name: Create Pull Request with updated asset files including package.json 57 | uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 # use 4.2.4 https://github.com/peter-evans/create-pull-request/releases/tag/v4.2.4 58 | env: 59 | RELEASE_TAG: ${{github.event.release.tag_name}} 60 | RELEASE_URL: ${{github.event.release.html_url}} 61 | with: 62 | token: ${{ secrets.GH_TOKEN }} 63 | commit-message: 'chore(release): ${{ env.RELEASE_TAG }}' 64 | committer: asyncapi-bot 65 | author: asyncapi-bot 66 | title: 'chore(release): ${{ env.RELEASE_TAG }}' 67 | body: 'Version bump in package.json for release [${{ env.RELEASE_TAG }}](${{ env.RELEASE_URL }})' 68 | branch: version-bump/${{ env.RELEASE_TAG }} 69 | - if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel 70 | name: Report workflow run status to Slack 71 | uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 #using https://github.com/8398a7/action-slack/releases/tag/v3.16.2 72 | with: 73 | status: ${{ job.status }} 74 | fields: repo,action,workflow 75 | text: 'Unable to bump the version in package.json after the release' 76 | env: 77 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} -------------------------------------------------------------------------------- /test/utils.spec.ts: -------------------------------------------------------------------------------- 1 | import { serializeInput, objectToSchema, dotsToSlashes, isPlainObject, createRefObject, createRefPath, isRefObject, getValueByRef, sortObjectKeys } from '../src/utils'; 2 | 3 | describe('utils', () => { 4 | describe('serializeInput()', () => { 5 | it('should serialize JSON', () => { 6 | const input = '{"foo": "bar"}'; 7 | const output = serializeInput(input); 8 | 9 | expect(output.format).toEqual('json'); 10 | expect(output.document).toEqual({foo: "bar"}); 11 | }); 12 | 13 | it('should serialize YAML', () => { 14 | const input = 'foo: bar'; 15 | const output = serializeInput(input); 16 | 17 | expect(output.format).toEqual('yaml'); 18 | expect(output.document).toEqual({foo: "bar"}); 19 | }); 20 | 21 | it('should serialize YAML (with JSON syntax)', () => { 22 | const input = '{foo: bar}'; 23 | const output = serializeInput(input); 24 | 25 | expect(output.format).toEqual('yaml'); 26 | expect(output.document).toEqual({foo: "bar"}); 27 | }); 28 | 29 | it('should throw error', () => { 30 | const input = '%{foo: bar}'; 31 | expect(() => serializeInput(input)).toThrow('AsyncAPI document must be a valid JSON or YAML document.'); 32 | }); 33 | }); 34 | 35 | describe('objectToSchema()', () => { 36 | it('should create object schema', () => { 37 | const input = { someProperty: { type: 'string' } }; 38 | expect(objectToSchema(input)).toEqual({ type: 'object', properties: { ...input } }); 39 | }); 40 | }); 41 | 42 | describe('dotsToSlashes()', () => { 43 | it('should convert dots to slashes', () => { 44 | expect(dotsToSlashes('some.long.path')).toEqual('some/long/path'); 45 | }); 46 | }); 47 | 48 | describe('isPlainObject()', () => { 49 | it('is plain object', () => { 50 | expect(isPlainObject({})).toEqual(true); 51 | }); 52 | 53 | it('is not plain object (array case)', () => { 54 | expect(isPlainObject([])).toEqual(false); 55 | }); 56 | 57 | it('is not plain object (null case)', () => { 58 | expect(isPlainObject(null)).toEqual(false); 59 | }); 60 | 61 | it('is not plain object (primitive case)', () => { 62 | expect(isPlainObject(2137)).toEqual(false); 63 | }); 64 | }); 65 | 66 | describe('createRefObject()', () => { 67 | it('should create ref object', () => { 68 | expect(createRefObject('components', 'channel', 'someChannel')).toEqual({ 69 | $ref: '#/components/channel/someChannel', 70 | }); 71 | }); 72 | }); 73 | 74 | describe('createRefObject()', () => { 75 | it('should create ref object', () => { 76 | expect(createRefPath('components', 'channel', 'someChannel')).toEqual('#/components/channel/someChannel'); 77 | }); 78 | }); 79 | 80 | describe('isRefObject()', () => { 81 | it('is ref object', () => { 82 | expect(isRefObject({ $ref: '#/components/channel/someChannel' })).toEqual(true); 83 | }); 84 | 85 | it('is not ref object', () => { 86 | expect(isRefObject({})).toEqual(false); 87 | }); 88 | }); 89 | 90 | describe('getValueByRef()', () => { 91 | const data = { 92 | components: { 93 | schemas: { 94 | someSchema: { 95 | type: 'string' 96 | } 97 | } 98 | } 99 | } 100 | 101 | it('should return value', () => { 102 | expect(getValueByRef(data, '#/components/schemas/someSchema')).toEqual(data.components.schemas.someSchema); 103 | }); 104 | 105 | it('should return undefined if path does not exist', () => { 106 | expect(getValueByRef(data, '#/components/schemas/anotherSchema')).toEqual(undefined); 107 | }); 108 | 109 | it('should return undefined if ref is invalid', () => { 110 | expect(getValueByRef(data, 'components/schemas/someSchema')).toEqual(undefined); 111 | }); 112 | }); 113 | 114 | describe('sortObjectKeys()', () => { 115 | it('should sort keys in given order', () => { 116 | const data = { 117 | first: '', 118 | third: '', 119 | next: '', 120 | second: '', 121 | }; 122 | 123 | const sorted = sortObjectKeys(data, ['first', 'second', 'third']); 124 | expect(Object.keys(sorted)).toEqual(['first', 'second', 'third', 'next']); 125 | }); 126 | }); 127 | }); 128 | -------------------------------------------------------------------------------- /test/input/2.6.0/for-3.0.0-with-servers-and-channels-components.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.6.0 2 | 3 | info: 4 | title: AsyncAPI Sample App 5 | version: 1.0.1 6 | description: This is a sample app. 7 | 8 | servers: 9 | default: 10 | url: 'api.streetlights.smartylighting.com:{port}' 11 | description: Test broker 12 | variables: 13 | port: 14 | description: Secure connection (TLS) is available through port 8883. 15 | default: '1883' 16 | enum: 17 | - '1883' 18 | - '8883' 19 | protocol: mqtt 20 | security: 21 | - apiKey: [] 22 | - flows: ['write:pets'] 23 | referenced: 24 | $ref: '#/components/servers/withProtocol' 25 | 26 | channels: 27 | 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured': 28 | servers: 29 | - production 30 | parameters: 31 | streetlightId: 32 | $ref: '#/components/parameters/streetlightId' 33 | publish: 34 | operationId: lightMeasured 35 | message: 36 | payload: 37 | type: object 38 | 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on': 39 | $ref: '#/components/channels/usedChannel' 40 | 41 | components: 42 | servers: 43 | production: 44 | url: 'api.streetlights.smartylighting.com:{port}/some/path' 45 | description: Test broker 46 | variables: 47 | port: 48 | description: Secure connection (TLS) is available through port 8883. 49 | default: '1883' 50 | enum: 51 | - '1883' 52 | - '8883' 53 | protocol: mqtt 54 | security: 55 | - apiKey: [] 56 | withProtocol: 57 | url: 'mqtt://api.streetlights.smartylighting.com:{port}/some/path' 58 | description: Test broker 59 | variables: 60 | port: 61 | description: Secure connection (TLS) is available through port 8883. 62 | default: '1883' 63 | enum: 64 | - '1883' 65 | - '8883' 66 | protocol: mqtt 67 | security: 68 | - apiKey: [] 69 | channels: 70 | usedChannel: 71 | servers: 72 | - default 73 | - production 74 | parameters: 75 | streetlightId: 76 | $ref: '#/components/parameters/streetlightId' 77 | publish: 78 | message: 79 | $ref: '#/components/messages/lightMeasured' 80 | subscribe: 81 | message: 82 | oneOf: 83 | - $ref: '#/components/messages/turnOnOff' 84 | - messageId: customMessageId 85 | payload: 86 | type: object 87 | - payload: 88 | type: object 89 | - $ref: 'https://example.com/message' 90 | unusedChannel: 91 | parameters: 92 | streetlightId: 93 | $ref: '#/components/parameters/streetlightId' 94 | subscribe: 95 | operationId: dimLight 96 | message: 97 | $ref: '#/components/messages/dimLight' 98 | security: 99 | - flows: ['write:pets'] 100 | messages: 101 | lightMeasured: 102 | summary: >- 103 | Inform about environmental lighting conditions for a particular 104 | streetlight. 105 | payload: 106 | $ref: '#/components/schemas/lightMeasuredPayload' 107 | turnOnOff: 108 | summary: Command a particular streetlight to turn the lights on or off. 109 | payload: 110 | $ref: '#/components/schemas/turnOnOffPayload' 111 | dimLight: 112 | summary: Command a particular streetlight to dim the lights. 113 | payload: 114 | $ref: '#/components/schemas/dimLightPayload' 115 | schemas: 116 | sentAt: 117 | type: string 118 | format: date-time 119 | description: Date and time when the message was sent. 120 | securitySchemes: 121 | apiKey: 122 | type: apiKey 123 | in: user 124 | description: Provide your API key as the user and leave the password empty. 125 | flows: 126 | type: oauth2 127 | flows: 128 | implicit: 129 | authorizationUrl: https://example.com/api/oauth/dialog 130 | scopes: 131 | write:pets: modify pets in your account 132 | read:pets: read your pets 133 | parameters: 134 | streetlightId: 135 | description: The ID of the streetlight. 136 | schema: 137 | type: string -------------------------------------------------------------------------------- /src/convert.ts: -------------------------------------------------------------------------------- 1 | import { dump } from 'js-yaml'; 2 | 3 | import { converters as firstConverters } from "./first-version"; 4 | import { converters as secondConverters } from "./second-version"; 5 | import { converters as thirdConverters } from "./third-version"; 6 | import { converters as openapiConverters } from "./openapi"; 7 | import { converters as postmanConverters } from "./postman-collection"; 8 | 9 | import { serializeInput } from "./utils"; 10 | 11 | import type { AsyncAPIDocument, AsyncAPIConvertVersion, OpenAPIConvertVersion, ConvertOptions, ConvertFunction, ConvertOpenAPIFunction, OpenAPIDocument, OpenAPIToAsyncAPIOptions, PostmanToAsyncAPIOptions } from './interfaces'; 12 | 13 | /** 14 | * Value for key (version) represents the function which converts specification from previous version to the given as key. 15 | */ 16 | const asyncAPIconverters: Record = { 17 | ...firstConverters, 18 | ...secondConverters, 19 | ...thirdConverters, 20 | }; 21 | 22 | const conversionVersions = Object.keys(asyncAPIconverters); 23 | 24 | export function convert(input: string, version: AsyncAPIConvertVersion, options?: ConvertOptions): string; 25 | export function convert(input: AsyncAPIDocument, version: AsyncAPIConvertVersion, options?: ConvertOptions): AsyncAPIDocument; 26 | export function convert(input: string | AsyncAPIDocument, version: AsyncAPIConvertVersion , options: ConvertOptions= {}): string | AsyncAPIDocument { 27 | const { format, document } = serializeInput(input); 28 | 29 | const asyncapiVersion = document.asyncapi; 30 | let fromVersion = conversionVersions.indexOf(asyncapiVersion); 31 | const toVersion = conversionVersions.indexOf(version); 32 | 33 | if (fromVersion === -1 || toVersion === -1) { 34 | throw new Error(`Cannot convert from ${asyncapiVersion} to ${version}.`); 35 | } 36 | if (fromVersion > toVersion) { 37 | throw new Error(`Cannot downgrade from ${asyncapiVersion} to ${version}.`); 38 | } 39 | if (fromVersion === toVersion) { 40 | throw new Error(`Cannot convert to the same version.`); 41 | } 42 | 43 | // add 1 to `fromVersion` because we convert from previous to next 44 | fromVersion++; 45 | let converted = document as AsyncAPIDocument; 46 | for (let i = fromVersion; i <= toVersion; i++) { 47 | const v = conversionVersions[i] as AsyncAPIConvertVersion; 48 | converted = asyncAPIconverters[v](converted, options); 49 | } 50 | 51 | if (format === 'yaml') { 52 | return dump(converted, { skipInvalid: true }); 53 | } 54 | return converted; 55 | } 56 | 57 | export function convertOpenAPI(input: string ,version: OpenAPIConvertVersion,options?: OpenAPIToAsyncAPIOptions): string; 58 | export function convertOpenAPI(input: OpenAPIDocument, version: OpenAPIConvertVersion ,options?: OpenAPIToAsyncAPIOptions): AsyncAPIDocument; 59 | export function convertOpenAPI(input: string | OpenAPIDocument, version: OpenAPIConvertVersion, options: OpenAPIToAsyncAPIOptions = {}): string | AsyncAPIDocument { 60 | 61 | const { format, document } = serializeInput(input); 62 | const openApiVersion = document.openapi; 63 | const converterVersion = openApiVersion; 64 | 65 | const openapiToAsyncapiConverter = openapiConverters[converterVersion as OpenAPIConvertVersion] as ConvertOpenAPIFunction; 66 | 67 | if (!openapiToAsyncapiConverter) { 68 | throw new Error(`We are not able to convert OpenAPI ${converterVersion} to AsyncAPI, please raise a feature request.`); 69 | } 70 | 71 | const convertedAsyncAPI = openapiToAsyncapiConverter(document as OpenAPIDocument, options); 72 | 73 | if (format === "yaml") { 74 | return dump(convertedAsyncAPI, { skipInvalid: true }); 75 | } 76 | return convertedAsyncAPI; 77 | } 78 | 79 | export function convertPostman(input: string, version: OpenAPIConvertVersion, options?: PostmanToAsyncAPIOptions ): string; 80 | export function convertPostman(input: Record, version: OpenAPIConvertVersion, options?: PostmanToAsyncAPIOptions): AsyncAPIDocument; 81 | export function convertPostman(input: string | Record, version: OpenAPIConvertVersion, options: PostmanToAsyncAPIOptions={}): string | AsyncAPIDocument { 82 | const { format, document } = serializeInput(input); 83 | const postmantoAsyncapiConverter = postmanConverters[version]; 84 | 85 | const convertedAsyncAPI = postmantoAsyncapiConverter(document as any, options); 86 | 87 | if (format === "yaml") { 88 | return dump(convertedAsyncAPI, { skipInvalid: true }); 89 | } 90 | return convertedAsyncAPI; 91 | } 92 | -------------------------------------------------------------------------------- /.github/workflows/automerge-for-humans-merging.yml: -------------------------------------------------------------------------------- 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 allow people to merge PR without a need of maintainer doing it. If all checks are in place (including maintainers approval) - JUST MERGE IT! 5 | name: Automerge For Humans 6 | 7 | on: 8 | pull_request_target: 9 | types: 10 | - labeled 11 | - unlabeled 12 | - synchronize 13 | - opened 14 | - edited 15 | - ready_for_review 16 | - reopened 17 | - unlocked 18 | 19 | jobs: 20 | automerge-for-humans: 21 | # it runs only if PR actor is not a bot, at least not a bot that we know 22 | if: | 23 | github.event.pull_request.draft == false && 24 | (github.event.pull_request.user.login != 'asyncapi-bot' || 25 | github.event.pull_request.user.login != 'dependabot[bot]' || 26 | github.event.pull_request.user.login != 'dependabot-preview[bot]') 27 | runs-on: ubuntu-latest 28 | steps: 29 | - name: Get PR authors 30 | id: authors 31 | uses: actions/github-script@v7 32 | with: 33 | script: | 34 | // Get paginated list of all commits in the PR 35 | try { 36 | const commitOpts = github.rest.pulls.listCommits.endpoint.merge({ 37 | owner: context.repo.owner, 38 | repo: context.repo.repo, 39 | pull_number: context.issue.number 40 | }); 41 | 42 | const commits = await github.paginate(commitOpts); 43 | 44 | if (commits.length === 0) { 45 | core.setFailed('No commits found in the PR'); 46 | return ''; 47 | } 48 | 49 | // Get unique authors from the commits list 50 | const authors = commits.reduce((acc, commit) => { 51 | const username = commit.author?.login || commit.commit.author?.name; 52 | if (username && !acc[username]) { 53 | acc[username] = { 54 | name: commit.commit.author?.name, 55 | email: commit.commit.author?.email, 56 | } 57 | } 58 | 59 | return acc; 60 | }, {}); 61 | 62 | return authors; 63 | } catch (error) { 64 | core.setFailed(error.message); 65 | return []; 66 | } 67 | 68 | - name: Create commit message 69 | id: create-commit-message 70 | uses: actions/github-script@v7 71 | with: 72 | script: | 73 | const authors = ${{ steps.authors.outputs.result }}; 74 | 75 | if (Object.keys(authors).length === 0) { 76 | core.setFailed('No authors found in the PR'); 77 | return ''; 78 | } 79 | 80 | // Create a string of the form "Co-authored-by: Name " 81 | // ref: https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors 82 | const coAuthors = Object.values(authors).map(author => { 83 | return `Co-authored-by: ${author.name} <${author.email}>`; 84 | }).join('\n'); 85 | 86 | core.debug(coAuthors);; 87 | 88 | return coAuthors; 89 | 90 | - name: Automerge PR 91 | uses: pascalgn/automerge-action@22948e0bc22f0aa673800da838595a3e7347e584 #v0.15.6 https://github.com/pascalgn/automerge-action/releases/tag/v0.15.6 92 | env: 93 | GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" 94 | MERGE_LABELS: "!do-not-merge,ready-to-merge" 95 | MERGE_METHOD: "squash" 96 | # Using the output of the previous step (`Co-authored-by: ...` lines) as commit description. 97 | # Important to keep 2 empty lines as https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line mentions 98 | MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})\n\n\n${{ fromJSON(steps.create-commit-message.outputs.result) }}" 99 | MERGE_RETRIES: "20" 100 | MERGE_RETRY_SLEEP: "30000" 101 | -------------------------------------------------------------------------------- /.github/workflows/welcome-first-time-contrib.yml: -------------------------------------------------------------------------------- 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 | name: Welcome first time contributors 5 | 6 | on: 7 | pull_request_target: 8 | types: 9 | - opened 10 | issues: 11 | types: 12 | - opened 13 | 14 | jobs: 15 | welcome: 16 | name: Post welcome message 17 | if: ${{ !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors[bot]"]'), github.actor) }} 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/github-script@v7 21 | with: 22 | github-token: ${{ secrets.GITHUB_TOKEN }} 23 | script: | 24 | const issueMessage = `Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our [contributors guide](https://github.com/asyncapi/community/blob/master/CONTRIBUTING.md) and the instructions about a [basic recommended setup](https://github.com/asyncapi/community/blob/master/git-workflow.md) useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out [this issue](https://github.com/asyncapi/asyncapi/issues/115).`; 25 | const prMessage = `Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our [contributors guide](https://github.com/asyncapi/community/blob/master/CONTRIBUTING.md) useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out [this issue](https://github.com/asyncapi/asyncapi/issues/115).`; 26 | if (!issueMessage && !prMessage) { 27 | throw new Error('Action must have at least one of issue-message or pr-message set'); 28 | } 29 | const isIssue = !!context.payload.issue; 30 | let isFirstContribution; 31 | if (isIssue) { 32 | const query = `query($owner:String!, $name:String!, $contributer:String!) { 33 | repository(owner:$owner, name:$name){ 34 | issues(first: 1, filterBy: {createdBy:$contributer}){ 35 | totalCount 36 | } 37 | } 38 | }`; 39 | const variables = { 40 | owner: context.repo.owner, 41 | name: context.repo.repo, 42 | contributer: context.payload.sender.login 43 | }; 44 | const { repository: { issues: { totalCount } } } = await github.graphql(query, variables); 45 | isFirstContribution = totalCount === 1; 46 | } else { 47 | const query = `query($qstr: String!) { 48 | search(query: $qstr, type: ISSUE, first: 1) { 49 | issueCount 50 | } 51 | }`; 52 | const variables = { 53 | "qstr": `repo:${context.repo.owner}/${context.repo.repo} type:pr author:${context.payload.sender.login}`, 54 | }; 55 | const { search: { issueCount } } = await github.graphql(query, variables); 56 | isFirstContribution = issueCount === 1; 57 | } 58 | 59 | if (!isFirstContribution) { 60 | console.log(`Not the users first contribution.`); 61 | return; 62 | } 63 | const message = isIssue ? issueMessage : prMessage; 64 | // Add a comment to the appropriate place 65 | if (isIssue) { 66 | const issueNumber = context.payload.issue.number; 67 | console.log(`Adding message: ${message} to issue #${issueNumber}`); 68 | await github.rest.issues.createComment({ 69 | owner: context.payload.repository.owner.login, 70 | repo: context.payload.repository.name, 71 | issue_number: issueNumber, 72 | body: message 73 | }); 74 | } 75 | else { 76 | const pullNumber = context.payload.pull_request.number; 77 | console.log(`Adding message: ${message} to pull request #${pullNumber}`); 78 | await github.rest.pulls.createReview({ 79 | owner: context.payload.repository.owner.login, 80 | repo: context.payload.repository.name, 81 | pull_number: pullNumber, 82 | body: message, 83 | event: 'COMMENT' 84 | }); 85 | } 86 | -------------------------------------------------------------------------------- /test/output/2.0.0-rc1/gitter-streaming.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.0.0-rc1 2 | info: 3 | title: Gitter Streaming API 4 | version: 1.0.0 5 | servers: 6 | - url: 'https://stream.gitter.im/v1/rooms/{roomId}/{resource}' 7 | variables: 8 | roomId: 9 | description: Id of the Gitter room. 10 | resource: 11 | description: The resource to consume. 12 | enum: 13 | - chatMessages 14 | - events 15 | protocol: https 16 | protocolVersion: '1.1' 17 | security: 18 | - httpBearerToken: [] 19 | components: 20 | securitySchemes: 21 | httpBearerToken: 22 | type: http 23 | scheme: bearer 24 | messages: 25 | chatMessage: 26 | summary: >- 27 | A message represents an individual chat message sent to a room. They are 28 | a sub-resource of a room. 29 | payload: 30 | type: object 31 | properties: 32 | id: 33 | type: string 34 | description: ID of the message. 35 | text: 36 | type: string 37 | description: Original message in plain-text/markdown. 38 | html: 39 | type: string 40 | description: HTML formatted message. 41 | sent: 42 | type: string 43 | format: date-time 44 | description: ISO formatted date of the message. 45 | fromUser: 46 | type: object 47 | description: User that sent the message. 48 | properties: 49 | id: 50 | type: string 51 | description: Gitter User ID. 52 | username: 53 | type: string 54 | description: Gitter/GitHub username. 55 | displayName: 56 | type: string 57 | description: Gitter/GitHub user real name. 58 | url: 59 | type: string 60 | description: Path to the user on Gitter. 61 | avatarUrl: 62 | type: string 63 | format: uri 64 | description: User avatar URI. 65 | avatarUrlSmall: 66 | type: string 67 | format: uri 68 | description: User avatar URI (small). 69 | avatarUrlMedium: 70 | type: string 71 | format: uri 72 | description: User avatar URI (medium). 73 | v: 74 | type: number 75 | description: Version. 76 | gv: 77 | type: string 78 | description: Stands for "Gravatar version" and is used for cache busting. 79 | unread: 80 | type: boolean 81 | description: Boolean that indicates if the current user has read the message. 82 | readBy: 83 | type: number 84 | description: Number of users that have read the message. 85 | urls: 86 | type: array 87 | description: List of URLs present in the message. 88 | items: 89 | type: string 90 | format: uri 91 | mentions: 92 | type: array 93 | description: List of @Mentions in the message. 94 | items: 95 | type: object 96 | properties: 97 | screenName: 98 | type: string 99 | userId: 100 | type: string 101 | userIds: 102 | type: array 103 | items: 104 | type: string 105 | issues: 106 | type: array 107 | description: 'List of #Issues referenced in the message.' 108 | items: 109 | type: object 110 | properties: 111 | number: 112 | type: string 113 | meta: 114 | type: array 115 | description: Metadata. This is currently not used for anything. 116 | items: {} 117 | v: 118 | type: number 119 | description: Version. 120 | gv: 121 | type: string 122 | description: Stands for "Gravatar version" and is used for cache busting. 123 | heartbeat: 124 | summary: Its purpose is to keep the connection alive. 125 | payload: 126 | type: string 127 | enum: 128 | - |+ 129 | 130 | channels: 131 | /: 132 | publish: 133 | message: 134 | oneOf: 135 | - $ref: '#/components/messages/chatMessage' 136 | - $ref: '#/components/messages/heartbeat' 137 | -------------------------------------------------------------------------------- /test/input/1.2.0/gitter-streaming.yml: -------------------------------------------------------------------------------- 1 | asyncapi: '1.2.0' 2 | info: 3 | title: Gitter Streaming API 4 | version: '1.0.0' 5 | 6 | servers: 7 | - url: https://stream.gitter.im/v1/rooms/{roomId}/{resource} 8 | scheme: https 9 | schemeVersion: '1.1' 10 | variables: 11 | roomId: 12 | description: Id of the Gitter room. 13 | resource: 14 | description: The resource to consume. 15 | enum: 16 | - chatMessages 17 | - events 18 | 19 | security: 20 | - httpBearerToken: [] 21 | 22 | stream: 23 | framing: 24 | type: 'chunked' 25 | delimiter: '\n' 26 | read: 27 | - $ref: '#/components/messages/chatMessage' 28 | - $ref: '#/components/messages/heartbeat' 29 | 30 | components: 31 | securitySchemes: 32 | httpBearerToken: 33 | type: http 34 | scheme: bearer 35 | messages: 36 | chatMessage: 37 | summary: >- 38 | A message represents an individual chat message sent to a room. 39 | They are a sub-resource of a room. 40 | payload: 41 | type: object 42 | properties: 43 | id: 44 | type: string 45 | description: ID of the message. 46 | text: 47 | type: string 48 | description: Original message in plain-text/markdown. 49 | html: 50 | type: string 51 | description: HTML formatted message. 52 | sent: 53 | type: string 54 | format: date-time 55 | description: ISO formatted date of the message. 56 | fromUser: 57 | type: object 58 | description: User that sent the message. 59 | properties: 60 | id: 61 | type: string 62 | description: Gitter User ID. 63 | username: 64 | type: string 65 | description: Gitter/GitHub username. 66 | displayName: 67 | type: string 68 | description: Gitter/GitHub user real name. 69 | url: 70 | type: string 71 | description: Path to the user on Gitter. 72 | avatarUrl: 73 | type: string 74 | format: uri 75 | description: User avatar URI. 76 | avatarUrlSmall: 77 | type: string 78 | format: uri 79 | description: User avatar URI (small). 80 | avatarUrlMedium: 81 | type: string 82 | format: uri 83 | description: User avatar URI (medium). 84 | v: 85 | type: number 86 | description: Version. 87 | gv: 88 | type: string 89 | description: Stands for "Gravatar version" and is used for cache busting. 90 | unread: 91 | type: boolean 92 | description: Boolean that indicates if the current user has read the message. 93 | readBy: 94 | type: number 95 | description: Number of users that have read the message. 96 | urls: 97 | type: array 98 | description: List of URLs present in the message. 99 | items: 100 | type: string 101 | format: uri 102 | mentions: 103 | type: array 104 | description: List of @Mentions in the message. 105 | items: 106 | type: object 107 | properties: 108 | screenName: 109 | type: string 110 | userId: 111 | type: string 112 | userIds: 113 | type: array 114 | items: 115 | type: string 116 | issues: 117 | type: array 118 | description: 'List of #Issues referenced in the message.' 119 | items: 120 | type: object 121 | properties: 122 | number: 123 | type: string 124 | meta: 125 | type: array 126 | description: Metadata. This is currently not used for anything. 127 | items: {} 128 | v: 129 | type: number 130 | description: Version. 131 | gv: 132 | type: string 133 | description: Stands for "Gravatar version" and is used for cache busting. 134 | 135 | heartbeat: 136 | summary: Its purpose is to keep the connection alive. 137 | payload: 138 | type: string 139 | enum: 140 | - "\n" 141 | -------------------------------------------------------------------------------- /test/output/2.0.0-rc2/gitter-streaming.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.0.0-rc2 2 | info: 3 | title: Gitter Streaming API 4 | version: 1.0.0 5 | servers: 6 | default: 7 | url: 'https://stream.gitter.im/v1/rooms/{roomId}/{resource}' 8 | variables: 9 | roomId: 10 | description: Id of the Gitter room. 11 | resource: 12 | description: The resource to consume. 13 | enum: 14 | - chatMessages 15 | - events 16 | protocol: https 17 | protocolVersion: '1.1' 18 | security: 19 | - httpBearerToken: [] 20 | components: 21 | securitySchemes: 22 | httpBearerToken: 23 | type: http 24 | scheme: bearer 25 | messages: 26 | chatMessage: 27 | summary: >- 28 | A message represents an individual chat message sent to a room. They are 29 | a sub-resource of a room. 30 | payload: 31 | type: object 32 | properties: 33 | id: 34 | type: string 35 | description: ID of the message. 36 | text: 37 | type: string 38 | description: Original message in plain-text/markdown. 39 | html: 40 | type: string 41 | description: HTML formatted message. 42 | sent: 43 | type: string 44 | format: date-time 45 | description: ISO formatted date of the message. 46 | fromUser: 47 | type: object 48 | description: User that sent the message. 49 | properties: 50 | id: 51 | type: string 52 | description: Gitter User ID. 53 | username: 54 | type: string 55 | description: Gitter/GitHub username. 56 | displayName: 57 | type: string 58 | description: Gitter/GitHub user real name. 59 | url: 60 | type: string 61 | description: Path to the user on Gitter. 62 | avatarUrl: 63 | type: string 64 | format: uri 65 | description: User avatar URI. 66 | avatarUrlSmall: 67 | type: string 68 | format: uri 69 | description: User avatar URI (small). 70 | avatarUrlMedium: 71 | type: string 72 | format: uri 73 | description: User avatar URI (medium). 74 | v: 75 | type: number 76 | description: Version. 77 | gv: 78 | type: string 79 | description: Stands for "Gravatar version" and is used for cache busting. 80 | unread: 81 | type: boolean 82 | description: Boolean that indicates if the current user has read the message. 83 | readBy: 84 | type: number 85 | description: Number of users that have read the message. 86 | urls: 87 | type: array 88 | description: List of URLs present in the message. 89 | items: 90 | type: string 91 | format: uri 92 | mentions: 93 | type: array 94 | description: List of @Mentions in the message. 95 | items: 96 | type: object 97 | properties: 98 | screenName: 99 | type: string 100 | userId: 101 | type: string 102 | userIds: 103 | type: array 104 | items: 105 | type: string 106 | issues: 107 | type: array 108 | description: 'List of #Issues referenced in the message.' 109 | items: 110 | type: object 111 | properties: 112 | number: 113 | type: string 114 | meta: 115 | type: array 116 | description: Metadata. This is currently not used for anything. 117 | items: {} 118 | v: 119 | type: number 120 | description: Version. 121 | gv: 122 | type: string 123 | description: Stands for "Gravatar version" and is used for cache busting. 124 | heartbeat: 125 | summary: Its purpose is to keep the connection alive. 126 | payload: 127 | type: string 128 | enum: 129 | - |+ 130 | 131 | channels: 132 | /: 133 | publish: 134 | message: 135 | oneOf: 136 | - $ref: '#/components/messages/chatMessage' 137 | - $ref: '#/components/messages/heartbeat' 138 | --------------------------------------------------------------------------------