Convert AsyncAPI documents older to newer versions.
npm i @asyncapi/converter
To convert an AsyncAPi document in the console needs the official AsyncAPI CLI.
If you don't have CLI installed, run this command to install the CLI globally on your system:
npm install -g @asyncapi/cli
Minimal usage example with output given:
asyncapi convert streetlights.yml -o streetlights2.yml
# Result:
asyncapi: '2.0.0'
channels:
...
Convert to specific version:
asyncapi convert streetlights.yml -o streetlights2.yml -t 2.3.0
# Result:
asyncapi: '2.3.0'
channels:
...
const fs = require('fs');
const { convert } = require('@asyncapi/converter')
try {
const asyncapi = fs.readFileSync('streetlights.yml', 'utf-8')
console.log(convert(asyncapi, '2.0.0'));
} catch (e) {
console.error(e);
}
import { convert } from '@asyncapi/converter';
import type { ConvertVersion, ConvertOptions } from '@asyncapi/converter';
try {
const toVersion: ConvertVersion = '2.0.0';
const asyncapi = fs.readFileSync('streetlights.yml', 'utf-8')
console.log(convert(asyncapi, toVersion));
} catch (e) {
console.error(e)
}
- When converting from 1.x to 2.x, Streaming APIs (those using
stream
instead oftopics
orevents
) are converted correctly but information about framing type and delimiter is missing until a protocolInfo for that purpose is created.
- Setup project by installing dependencies
npm install
- Write code and tests.
- Make sure all tests pass
npm test
Read CONTRIBUTING guide.
Thanks goes to these wonderful people (emoji key):
Maciej Urbańczyk 🚧 💻 🐛 👀 |
Fran Méndez 🚧 💻 🐛 👀 |
Lukasz Gornicki 🚧 💻 🐛 👀 |
Germán Schnyder 💻 |
Barbara Czyż 🚇 |
depimomo 💻 |
Orville Daley 💻 |
Ryan R Sundberg 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!