Skip to content

Convert AsyncAPI documents from older to newer versions.

Notifications You must be signed in to change notification settings

magicmatatjahu/converter-js

 
 

Repository files navigation

AsyncAPI Converter

Convert AsyncAPI documents older to newer versions.

All Contributors

Installation

npm i @asyncapi/converter

Usage

From CLI

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:
...

In JS

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', {
    id: 'urn:com.asyncapi.streetlights'
  }));
} catch (e) {
  console.error(e);
}

In TS

import { convert } from '@asyncapi/converter';
import type { ConvertVersion, ConvertOptions } from '@asyncapi/converter';

try {
  const toVersion: ConvertVersion = '2.0.0';
  const options: ConvertOptions = {
    id: 'urn:com.asyncapi.streetlights'
  };

  const asyncapi = fs.readFileSync('streetlights.yml', 'utf-8')
  console.log(convert(asyncapi, toVersion, options));
} catch (e) {
  console.error(e)
}

Known missing features

  • When converting from 1.x to 2.x, Streaming APIs (those using stream instead of topics or events) are converted correctly but information about framing type and delimiter is missing until a protocolInfo for that purpose is created.

Development

  1. Setup project by installing dependencies npm install
  2. Write code and tests.
  3. Make sure all tests pass npm test

Contribution

Read CONTRIBUTING guide.

Contributors ✨

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!

About

Convert AsyncAPI documents from older to newer versions.

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%