Kind: global class
- Document
- new Document(AsyncAPIObject)
- .json() ⇒
Object
- .yml() ⇒
string
- .string() ⇒
string
Param | Type |
---|---|
AsyncAPIObject | Object |
Example
const document = new Document(bundledDocument);
console.log(document.json()); // get JSON object
console.log(document.yml()); // get YAML string
console.log(document.string()); // get JSON string
Kind: instance method of Document
Kind: instance method of Document
Kind: instance method of Document
bundle(files, [options]) ⇒ Document
Kind: global function
Param | Type | Description |
---|---|---|
files | string | Array.<string> |
One or more relative/absolute paths to AsyncAPI Documents that should be bundled. |
[options] | Object |
|
[options.base] | string |
One relative/absolute path to base object whose properties will be retained. |
[options.baseDir] | string |
One relative/absolute path to directory relative to which paths to AsyncAPI Documents that should be bundled will be resolved. |
[options.xOrigin] | boolean |
Pass |
Example
TypeScript
import { writeFileSync } from 'fs';
import bundle from '@asyncapi/bundler';
async function main() {
const document = await bundle(['social-media/comments-service/main.yaml'], {
baseDir: 'example-data',
xOrigin: true,
});
console.log(document.yml()); // the complete bundled AsyncAPI document
writeFileSync('asyncapi.yaml', document.yml()); // the complete bundled AsyncAPI document
}
main().catch(e => console.error(e));
JavaScript CJS module system
'use strict';
const { writeFileSync } = require('fs');
const bundle = require('@asyncapi/bundler');
async function main() {
const document = await bundle(['social-media/comments-service/main.yaml'], {
baseDir: 'example-data',
xOrigin: true,
});
writeFileSync('asyncapi.yaml', document.yml());
}
main().catch(e => console.error(e));
JavaScript ESM module system
'use strict';
import { writeFileSync } from 'fs';
import bundle from '@asyncapi/bundler';
async function main() {
const document = await bundle(['social-media/comments-service/main.yaml'], {
baseDir: 'example-data',
xOrigin: true,
});
writeFileSync('asyncapi.yaml', document.yml());
}
main().catch(e => console.error(e));