asyncapi-to-postman

0.1.0 • Public • Published

AsyncAPI 2.x to Postman Collection v2.1.0 Converter

Installation

npm i asyncapi-to-postman

Usage as a Node.js module

const a2p = require('asyncapi-to-postman')

const asyncapiYAML = `asyncapi: 2.1.0
info:
  title: Basic YAML
  version: 1.0.0
  description: A basic YAML AsyncAPI file

servers:
  dev:
    url: ws://localhost:3000
    protocol: ws

channels:
  test:
    publish:
      message:
        payload:
          type: object
          additionalProperties: false
          properties:
            testProp:
              type: string`

const options = {
  parser: {...}, // AsyncAPI parser options.
  serverName: 'dev', // Name of the AsyncAPI server to target.
}

const collection = await a2p.convert(asyncapiYAML, options)

// Or using promises syntax:

a2p
  .convert(asyncapiYAML, options)
  .then(collection => {
    // Do your stuff with the collection
  })
  .catch(console.error)

For more information about the AsyncAPI parser options, see its API documentation.

The returned collection is an instance of the Postman SDK Collection object.

Limitations

Postman Collection Auth

Only the first security scheme of the first provided server is included in the resulting collection. This is a limitation of the Postman Collection specification.

Mapping

Postman AsyncAPI
Collection Name info.title
Collection Version info.version
Collection Description info.description
Collection Variables servers.variables + channels.parameters
Collection Auth servers[0].security[0]
Item Name Publish to + channel name
Item Id channel.publish.operationId || publish-to- + channel name
Request URL server.url + channel name
Request Method (based in server.protocol)
Request Body (based in channel.publish.message.payload)
Request Headers (based in channel.publish.message.headers)
Request Description channel.publish.description

Readme

Keywords

none

Package Sidebar

Install

npm i asyncapi-to-postman

Weekly Downloads

0

Version

0.1.0

License

Apache-2.0

Unpacked Size

12.4 kB

Total Files

4

Last publish

Collaborators

  • fmvilas