Bundle multiple Specificatin files into one
Combine multiple AsyncAPI spec files into one complete spec file or resolve external $ref
's in one file.
As of now you can use AsyncAPI Bundler for two specific use cases -
- Merge different AsyncAPI specifications into one.
- Resolve all references from an single AsyncAPI document into a single file.
AsyncAPI-bundler could be easily used within your javascript projects as a Nodejs module.
const bundler = require('asyncapi-bundler');
const fs = require('fs');
const path = require('path');
const filePaths = ['./camera.yml','./audio.yml']
const document = await bundler.bundle(
filePaths.map(filePath => fs.readFileSync(path.resolve(filePaths), 'utf-8')),
{
base: fs.readFileSync(path.resolve('./base.yml'), 'utf-8')
}
);
console.log(document.json()); // the complete bundled asyncapi document.
Kind: global function
Param | Type | Description |
---|---|---|
files | Array.<string> | Array.<Object> |
files that are to be bundled |
options | Object |
|
options.base | string | object |
base object whose prperties will be retained. |
options.parser | Object |
asyncapi parser object |
options.validate | boolean |
pass false to not validate file before merge |