All Projects โ†’ asyncapi โ†’ Generator

asyncapi / Generator

Licence: apache-2.0
Use your AsyncAPI definition to generate literally anything. Markdown documentation, Node.js code, HTML documentation, anything!

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Generator

Pdoc
๐Ÿ โžก๏ธ ๐Ÿ“œ Auto-generate API documentation for Python projects
Stars: โœญ 604 (+154.85%)
Mutual labels:  documentation, generator
Docsify Tabs
A docsify.js plugin for rendering tabbed content from markdown
Stars: โœญ 65 (-72.57%)
Mutual labels:  documentation, generator
Easybook
Book publishing as easy as it should be (built with Symfony components)
Stars: โœญ 744 (+213.92%)
Mutual labels:  documentation, generator
Yii2 Apidoc
Yii 2 apidoc extension.
Stars: โœญ 236 (-0.42%)
Mutual labels:  documentation, generator
Terraform Docs
Generate documentation from Terraform modules in various output formats
Stars: โœญ 2,483 (+947.68%)
Mutual labels:  documentation, generator
Typedoc
Documentation generator for TypeScript projects.
Stars: โœญ 5,377 (+2168.78%)
Mutual labels:  documentation, generator
Papogen
Use Sass/CSS + Pug + Node.js to generate beautiful static website.
Stars: โœญ 37 (-84.39%)
Mutual labels:  documentation, generator
Compodoc
๐Ÿ“” The missing documentation tool for your Angular, Nest & Stencil application
Stars: โœญ 3,567 (+1405.06%)
Mutual labels:  documentation, generator
Generator Standard Readme
Scaffold out a Standard Readme
Stars: โœญ 150 (-36.71%)
Mutual labels:  documentation, generator
Easy Doc Bundle
Symfony application documentation generator
Stars: โœญ 99 (-58.23%)
Mutual labels:  documentation, generator
Verb
HEADS UP! Verb is going though a major transition, we've completely refactored everything from the ground up. If you're interested, please see the dev branch.
Stars: โœญ 442 (+86.5%)
Mutual labels:  documentation, generator
Cgx
๐Ÿ’ป๐Ÿ”ฅCLI to generate the recommended documentation/files to improve contribution (Github, Gitlab, CodeCommit and Bitbucket)
Stars: โœญ 190 (-19.83%)
Mutual labels:  documentation, generator
Assemble
Community
Stars: โœญ 3,995 (+1585.65%)
Mutual labels:  documentation, generator
Vim Doge
(Do)cumentation (Ge)nerator 10+ languages ๐Ÿ“š Generate proper code documentation skeletons with a single keypress. โšก๏ธ๐Ÿ”ฅ
Stars: โœญ 533 (+124.89%)
Mutual labels:  documentation, generator
Dokz
Effortless documentation with Next.js and MDX
Stars: โœญ 353 (+48.95%)
Mutual labels:  documentation, generator
Esview
ๆญค้กน็›ฎๅทฒๆš‚ๅœๅผ€ๅ‘
Stars: โœญ 761 (+221.1%)
Mutual labels:  generator, codegen
Openapi Typescript Codegen
NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification
Stars: โœญ 249 (+5.06%)
Mutual labels:  generator, codegen
Sourcedocs
Generate Markdown documentation from source code
Stars: โœญ 286 (+20.68%)
Mutual labels:  documentation, generator
Jsdoc To Markdown
Generate markdown documentation from jsdoc-annotated javascript
Stars: โœญ 1,199 (+405.91%)
Mutual labels:  documentation, generator
Apigen
PHP 7.1 ready Smart and Simple Documentation for your PHP project
Stars: โœญ 2,068 (+772.57%)
Mutual labels:  documentation, generator

AsyncAPI logo
AsyncAPI Generator

Use your AsyncAPI definition to generate literally anything. Markdown documentation, Node.js code, HTML documentation, anything!

npm npm

โš ๏ธ This package doesn't support AsyncAPI 1.x anymore. We recommend to upgrade to the latest AsyncAPI version using the AsyncAPI converter. If you need to convert documents on the fly, you may use the Node.js or Go converters.

Overview

Generator is a tool that you can use to generate whatever you want basing on the AsyncAPI specification file as an input.

To specify what exactly must be generated you create so called template. To create your own template, go to section that explains How to create a template.

There is a large number of templates that are ready to use and are officially supported by the AsyncAPI Initiative.

List of official generator templates

Template Name Description Source code
@asyncapi/nodejs-template Generates Nodejs service that uses Hermes package click here
@asyncapi/nodejs-ws-template Generates Nodejs service that supports WebSockets protocol only click here
@asyncapi/java-spring-template Generates Java Spring service click here
@asyncapi/java-spring-cloud-stream-template Generates Java Spring Cloud Stream service click here
@asyncapi/python-paho-template Generates Python service that uses Paho library click here
@asyncapi/html-template Generates HTML documentation site click here
@asyncapi/markdown-template Generates documentation in Markdown file click here
@asyncapi/ts-nats-template Generates TypeScript NATS client click here

You can find above templates and the ones provided by the community in this list

Requirements

  • Node.js v12.16 and higher
  • npm v6.13.7 and higher

Install both packages using official installer. After installation make sure both packages have proper version by running node -v and npm -v. To upgrade invalid npm version run npm install [email protected] -g

Generator is tested at the moment against Node 14 and NPM 6. Using newer versions is enabled but we do not guarantee they work well. Please provide feedback on the issues.

Using from the command-line interface (CLI)

Install the CLI

To use it as CLI, install generator globally:

npm install -g @asyncapi/generator

Update the CLI

You might want to update your local installation of generator for different reasons:

  • You want the latest generator to have its latest features. Perform usual installation and in case you had generator installed already, it will upgrade to latest available:
    npm install -g @asyncapi/generator
    
  • You want a specific version of the generator because your template might not be compatible with the latest generator. Check what version you need and perform installation, specifying the exact version with the @ character:
    npm install -g @asyncapi/[email protected]
    

Sometimes you have to force additional npm installation like this: npm install -g --force @asyncapi/generator

CLI usage

Usage: ag [options] <asyncapi> <template>

- <asyncapi>: Local path or URL pointing to AsyncAPI specification file
- <template>: Name of the generator template like for example @asyncapi/html-template or https://github.com/asyncapi/html-template

Options:
  -V, --version                  output the version number
  -d, --disable-hook [hooks...]  disable a specific hook type or hooks from given hook type
  --debug                        enable more specific errors in the console
  -i, --install                  installs the template and its dependencies (defaults to false)
  -n, --no-overwrite <glob>      glob or path of the file(s) to skip when regenerating
  -o, --output <outputDir>       directory where to put the generated files (defaults to current directory)
  -p, --param <name=value>       additional param to pass to templates
  --force-write                  force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)
  --watch-template               watches the template directory and the AsyncAPI document, and re-generate the files when changes occur. Ignores the output directory. This flag should be used only for template development.
  -h, --help                     display help for command
Click here to read more about supported values for the <template> parameter.
Templates are installable npm packages. Therefore, the value of <template> can be anything supported by npm install. Here's a summary of the possibilities:


  npm install [<@scope>/]<name>
  npm install [<@scope>/]<name>@<tag>
  npm install [<@scope>/]<name>@<version>
  npm install [<@scope>/]<name>@<version range>
  npm install <git-host>:<git-user>/<repo-name>
  npm install <git repo url>
  npm install <tarball file>
  npm install <tarball url>
  npm install <folder>

Global templates installed with yarn or npm

You can preinstall templates globally. The generator first tries to locate template in local dependencies and then in location where global packages are installed.

npm install -g @asyncapi/[email protected]
ag asyncapi.yaml @asyncapi/html-template
# The generator uses template in version 0.16.0 and not latest

CLI usage examples

The shortest possible syntax:

ag asyncapi.yaml @asyncapi/html-template

Generating from a URL:

ag https://bit.ly/asyncapi @asyncapi/html-template

Specify where to put the result:

ag asyncapi.yaml @asyncapi/html-template -o ./docs

Passing parameters to templates:

ag asyncapi.yaml @asyncapi/html-template -o ./docs -p title='Hello from param'

In the template you can use it like this: {{ params.title }}

Disabling the hooks:

ag asyncapi.yaml @asyncapi/html-template -o ./docs -d generate:before generate:after=foo,bar

The generator skips all hooks of the generate:before type and foo, bar hooks of the generate:after type.

Installing the template from a folder:

ag asyncapi.yaml ~/my-template

It creates a symbolic link to the target directory (~/my-template in this case).

Installing the template from a git URL:

ag asyncapi.yaml https://github.com/asyncapi/html-template.git

CLI usage with Docker

Install Docker first. Thanks to Docker you do not need Node.js even though the generator is written with it.

docker run --rm -it \
-v [ASYNCAPI SPEC FILE LOCATION]:/app/asyncapi.yml \
-v [GENERATED FILES LOCATION]:/app/output \
asyncapi/generator [COMMAND HERE]

# Example that you can run inside generator directory after cloning this repository. First you specify mount in location of your AsyncAPI specification file and then you mount in directory where generation result should be saved.
docker run --rm -it \
-v ${PWD}/test/docs/dummy.yml:/app/asyncapi.yml \
-v ${PWD}/output:/app/output \
asyncapi/generator -o /app/output /app/asyncapi.yml @asyncapi/html-template --force-write

CLI usage with npx instead of npm

The npx is very useful when you want to run Generator in CI/CD environment. In such a scenario, you do not want to install generator globally and most environments that provide Node.js and npm, also provide npx out of the box.

npx -p @asyncapi/generator ag ./asyncapi.yaml @asyncapi/html-template

Using as a module/package

Install the module

npm install @asyncapi/generator --save

Example using the module

Below you can find an example of HTML generation using official @asyncapi/html-template template and fetching the spec document from server like https://raw.githubusercontent.com/asyncapi/asyncapi/2.0.0/examples/2.0.0/streetlights.yml :

const path = require('path');
const generator = new Generator('@asyncapi/html-template', path.resolve(__dirname, 'example'));

try {
  await generator.generateFromURL('https://raw.githubusercontent.com/asyncapi/asyncapi/2.0.0/examples/2.0.0/streetlights.yml');
  console.log('Done!');
} catch (e) {
  console.error(e);
}

See API documentation for more example and full API reference information.

Generator version vs Template version

The Generator is a tool that you can use to generate whatever you want, taking an AsyncAPI specification file as the input. A template is a tool that uses Generator features and helpers to specify what should be generated.

In other words, a template depends on the Generator and its features. For example, it might work with the latest version of the Generator but not the previous ones.

The owner of the template specifies in the configuration what version of the Generator it is compatible with:

"generator": ">=0.50.0 <2.0.0",

The Generator doesn't work in case the template is not compatible:

Something went wrong:
Error: This template is not compatible with the current version of the generator (0.50.0). This template is compatible with the following version range: >=0.60.0 <2.0.0.
    at Generator.validateTemplateConfig (/Users/wookiee/.nvm/versions/node/v12.16.1/lib/node_modules/@asyncapi/generator/lib/generator.js:678:13)
    at Generator.loadTemplateConfig (/Users/wookiee/.nvm/versions/node/v12.16.1/lib/node_modules/@asyncapi/generator/lib/generator.js:663:16)
    at Generator.generate (/Users/wookiee/.nvm/versions/node/v12.16.1/lib/node_modules/@asyncapi/generator/lib/generator.js:146:18)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async /Users/wookiee/.nvm/versions/node/v12.16.1/lib/node_modules/@asyncapi/generator/cli.js:135:7

In case you use Generator CLI and a specific template on production, it is safer to lock to a specific version of the template and the Generator.

Instead of generating HTML with latest html-template and the generator CLI:

npm install -g @asyncapi/generator
ag asyncapi.yaml @asyncapi/html-template -o ./docs

Generate HTML with the version of the html-template and the Generator CLI that you are happy with:

npm install -g @asyncapi/[email protected]
ag asyncapi.yaml @asyncapi/[email protected] -o ./docs

Before using newer versions of the template, always look at the changelog first. Generator features are not important for you, just make sure to use a version compatible with the template.

How to create a template

To create your own template, for example code generator for some specific language and technology, learn from the following resources:

Contributing

Read CONTRIBUTING guide.

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Fran Mรฉndez

๐Ÿ’ฌ ๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿค” ๐Ÿšง ๐Ÿ”Œ ๐Ÿ‘€ โš ๏ธ โœ…

Jonas Lagoni

๐Ÿ’ฌ ๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿค” ๐Ÿ”Œ ๐Ÿ‘€ โš ๏ธ

Lukasz Gornicki

๐Ÿ’ฌ ๐Ÿ› ๐Ÿ“ ๐Ÿ’ป ๐Ÿ“– ๐Ÿค” ๐Ÿšง ๐Ÿ”Œ ๐Ÿ‘€ โš ๏ธ โœ… ๐Ÿš‡

Travis Reeder

๐Ÿš‡ ๐Ÿ“–

Semen

๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿค” ๐Ÿ”Œ ๐Ÿ‘€ โš ๏ธ

Waleed Ashraf

๐Ÿ’ป ๐Ÿ›

Sebastiรกn

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].