Use your AsyncAPI definition to generate literally anything. Markdown documentation, Node.js code, HTML documentation, anything!
npm install -g asyncapi-generator
Usage: ag [options] <asyncapi> <template>
Options:
-V, --version output the version number
-o, --output <outputDir> directory where to put the generated files (defaults to current directory)
-t, --templates <templateDir> directory where templates are located (defaults to internal templates directory)
-h, --help output usage information
The shortest possible syntax:
ag asyncapi.yaml markdown
Specify where to put the result:
ag -o ./docs asyncapi.yaml markdown
Generates a file of a given template, and returns the result as a string.
Name | Type | Required | Description |
---|---|---|---|
options | object |
Yes | An object containing all the options. |
options.templateDir | string |
No | Directory where to find the templates. Defaults to internal templates directory. |
options.template | string |
Yes | Name of the template you want to use. |
options.file | string |
Yes | Path to the file you want to generate. |
options.config | object |
Yes | An object containing configuration options. |
options.config.asyncapi | string |object |
Yes | Path to the AsyncAPI file to use. |
const generator = require('asyncapi-generator');
generator.generateTemplateFile({
template: 'html',
file: 'index.html',
config: {
asyncapi: path.resolve(__dirname, 'asyncapi.yml'),
}
})
.then((result) => {
// `result` is a string containing the generated file.
console.log(result);
})
.catch(console.error);
Gets a file of a given template, and returns the its content as a string.
Name | Type | Required | Description |
---|---|---|---|
options | object |
Yes | An object containing all the options. |
options.templateDir | string |
No | Directory where to find the templates. Defaults to internal templates directory. |
options.template | string |
Yes | Name of the template you want to use. |
options.file | string |
Yes | Path to the file you want to generate. |
const generator = require('asyncapi-generator');
generator.getTemplateFile({
template: 'html',
file: 'css/main.css',
})
.then((content) => {
console.log(result);
})
.catch(console.error);
- Node.js v7.6+
Contributions are more than welcome. If you want to make a contribution, please make sure you go through the following steps:
- Pick or create an issue. It's always a good idea to leave a message saying that you're going to work on it before you start any actual work.
- Fork the repository and work there.
- Open a Pull Request pointing to
develop
branch. - A maintainer will review and, eventually, merge your Pull Request. Please, be patient as most of us are doing this in our spare time.
If you're a maintainer, take it from here:
- Merge Pull Request into
develop
. - Make sure your local
develop
andmaster
branches are up to date. - Switch to
develop
branch. - Whenever you think it makes sense, make a release:
- From develop branch, run:
git flow release start X.X.X
. - In release branch, update version in
package.json
andpackage-lock.json
. - In release branch, run:
git flow release finish X.X.X
. - You should now be in
develop
branch. Run:git push --tags && git checkout master && git push
.
- From develop branch, run:
- Release to NPM should happen automatically. You can check status at https://travis-ci.org/asyncapi/asyncapi.
Fran Méndez (@fmvilas)