Scalar AsyncAPI Upgrader

Upgrade all your AsyncAPI documents to the latest and greatest version.

TypeScript Package

You can use the package in your Node.js/JavaScript/TypeScript projects:

npm add @scalar/asyncapi-upgrader

Usage

The upgrade function migrates any AsyncAPI 1.x, 2.x, or 3.0 document all the way to the latest version (3.1.0) in a single call.

import { upgrade } from '@scalar/asyncapi-upgrader'

const document = upgrade({
  asyncapi: '2.6.0',
  info: {
    title: 'Hello World',
    version: '1.0.0',
  },
  channels: {},
})

console.log(document.asyncapi)
// Output: 3.1.0

Documents without an asyncapi field are returned untouched, so it is safe to run upgrade on documents that might already be up to date.

From AsyncAPI 1.x to 2.6

import { upgradeFromOneToTwo } from '@scalar/asyncapi-upgrader/1.2-to-2.6'

const document = upgradeFromOneToTwo({
  asyncapi: '1.2.0',
  info: {
    title: 'Hello World',
    version: '1.0.0',
  },
})

console.log(document.asyncapi)
// Output: 2.6.0

From AsyncAPI 2.6 to 3.0

import { upgradeFromTwoToThree } from '@scalar/asyncapi-upgrader/2.6-to-3.0'

const document = upgradeFromTwoToThree({
  asyncapi: '2.6.0',
  info: {
    title: 'Hello World',
    version: '1.0.0',
  },
  channels: {},
})

console.log(document.asyncapi)
// Output: 3.0.0

From AsyncAPI 3.0 to 3.1

import { upgradeFromThreeToThreeOne } from '@scalar/asyncapi-upgrader/3.0-to-3.1'

const document = upgradeFromThreeToThreeOne({
  asyncapi: '3.0.0',
  info: {
    title: 'Hello World',
    version: '1.0.0',
  },
  channels: {},
})

console.log(document.asyncapi)
// Output: 3.1.0