Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fmvilas/asyncapi-to-postman
Creates a Postman collection from an AsyncAPI file.
https://github.com/fmvilas/asyncapi-to-postman
Last synced: 6 days ago
JSON representation
Creates a Postman collection from an AsyncAPI file.
- Host: GitHub
- URL: https://github.com/fmvilas/asyncapi-to-postman
- Owner: fmvilas
- Created: 2021-08-25T19:04:12.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-08-26T10:47:52.000Z (over 3 years ago)
- Last Synced: 2024-11-09T15:09:23.856Z (about 2 months ago)
- Language: JavaScript
- Size: 40 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AsyncAPI 2.x to Postman Collection v2.1.0 Converter
## Installation
```
npm i asyncapi-to-postman
```## Usage as a Node.js module
```js
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 fileservers:
dev:
url: ws://localhost:3000
protocol: wschannels:
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](https://github.com/asyncapi/parser-js/blob/master/API.md#module_@asyncapi/parser..parse).
The returned `collection` is an instance of the [Postman SDK Collection object](https://www.postmanlabs.com/postman-collection/Collection.html).
## 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](https://schema.postman.com/collection/json/v2.1.0/draft-07/docs/index.html).
## 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 |