Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions markdown/docs/tools/generator/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ weight: 75
---

Reference API documentation for AsyncAPI Generator library.
## Classes

<dl>
<dt><a href="#Generator">Generator</a></dt>
<dd></dd>
</dl>

## Members

<dl>
<dt><a href="#listBakedInTemplates">listBakedInTemplates</a> ⇒ <code>Array.&lt;Object&gt;</code></dt>
<dd><p>List core templates, optionally filter by type, stack, protocol, or target.
Use name of returned templates as input for the <code>generate</code> method for template generation. Such core templates code is part of the @asyncapi/generator package.</p></dd>
</dl>
Comment on lines +17 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use consistent terminology (“baked-in templates”) and fix grammar in Members description

Switch “core templates” to “baked-in templates” for consistency with the new docs and tighten the phrasing.

Apply this diff:

-<dd><p>List core templates, optionally filter by type, stack, protocol, or target.
-Use name of returned templates as input for the <code>generate</code> method for template generation. Such core templates code is part of the @asyncapi/generator package.</p></dd>
+<dd><p>List baked-in templates, optionally filtered by type, stack, protocol, or target.
+Use the returned template <em>name</em> as the <code>templateName</code> when calling the <code>Generator</code>. Baked-in template code ships with the <code>@asyncapi/generator</code> package.</p></dd>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<dt><a href="#listBakedInTemplates">listBakedInTemplates</a> ⇒ <code>Array.&lt;Object&gt;</code></dt>
<dd><p>List core templates, optionally filter by type, stack, protocol, or target.
Use name of returned templates as input for the <code>generate</code> method for template generation. Such core templates code is part of the @asyncapi/generator package.</p></dd>
</dl>
<dt><a href="#listBakedInTemplates">listBakedInTemplates</a> ⇒ <code>Array.&lt;Object&gt;</code></dt>
<dd><p>List baked-in templates, optionally filtered by type, stack, protocol, or target.
Use the returned template <em>name</em> as the <code>templateName</code> when calling the <code>Generator</code>. Baked-in template code ships with the <code>@asyncapi/generator</code> package.</p></dd>
</dl>
🤖 Prompt for AI Agents
In markdown/docs/tools/generator/api.md around lines 17 to 20, the Members
description uses inconsistent terminology ("core templates") and has awkward
phrasing; update the text to use "baked-in templates" consistently and tighten
grammar — e.g., replace occurrences of "core templates" with "baked-in
templates", reword the sentence to: "List baked-in templates; optionally filter
by type, stack, protocol, or target. Use the returned template names as input to
the generate method. Baked-in templates are included in the @asyncapi/generator
package." Ensure markup and code tags remain unchanged.



<a name="Generator"></a>

Expand Down Expand Up @@ -494,3 +509,20 @@ const content = await Generator.getTemplateFile('@asyncapi/html-template', 'part
const Generator = require('@asyncapi/generator');
const content = await Generator.getTemplateFile('@asyncapi/html-template', 'partials/content.html', '~/my-templates');
```

<a name="listBakedInTemplates"></a>

## listBakedInTemplates
List core templates, optionally filter by type, stack, protocol, or target.
Use name of returned templates as input for the `generate` method for template generation. Such core templates code is part of the @asyncapi/generator package.

**Kind**: global variable
**Returns**: `Array.<Object>` - Array of template objects matching the filter.
**Params**
Comment on lines +513 to +521
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

“Kind” is wrong; document full function signature and return shape

This section currently labels the API as a “global variable.” It is a callable function. Also, adding the parameter list to the heading and clarifying the return objects improves usability.

Apply this diff:

-## listBakedInTemplates
-List core templates, optionally filter by type, stack, protocol, or target.
-Use name of returned templates as input for the `generate` method for template generation. Such core templates code is part of the @asyncapi/generator package.
-
-**Kind**: global variable  
-**Returns**: `Array.<Object>` - Array of template objects matching the filter.  
+## listBakedInTemplates([filter]) ⇒ `Array.<Object>`
+List baked-in templates, optionally filtered by type, stack, protocol, or target.
+Use the returned template name as the `templateName` when calling the `Generator`. Baked-in templates are bundled with `@asyncapi/generator`.
+
+**Kind**: global function  
+**Returns**: `Array.<{ name: string, type: string, protocol?: string, target: string, stack?: string }>` - Template descriptors matching the filter.  
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<a name="listBakedInTemplates"></a>
## listBakedInTemplates
List core templates, optionally filter by type, stack, protocol, or target.
Use name of returned templates as input for the `generate` method for template generation. Such core templates code is part of the @asyncapi/generator package.
**Kind**: global variable
**Returns**: `Array.<Object>` - Array of template objects matching the filter.
**Params**
<a name="listBakedInTemplates"></a>
## listBakedInTemplates([filter]) ⇒ `Array.<Object>`
List baked-in templates, optionally filtered by type, stack, protocol, or target.
Use the returned template name as the `templateName` when calling the `Generator`. Baked-in templates are bundled with `@asyncapi/generator`.
**Kind**: global function
**Returns**: `Array.<{ name: string, type: string, protocol?: string, target: string, stack?: string }>` - Template descriptors matching the filter.
**Params**
🧰 Tools
🪛 LanguageTool

[grammar] ~516-~516: There might be a mistake here.
Context: ...er by type, stack, protocol, or target. Use name of returned templates as input for...

(QB_NEW_EN)


[grammar] ~517-~517: There might be a mistake here.
Context: ...e, stack, protocol, or target. Use name of returned templates as input for the `ge...

(QB_NEW_EN)

🤖 Prompt for AI Agents
In markdown/docs/tools/generator/api.md around lines 513 to 521, the entry for
listBakedInTemplates incorrectly labels the API as a "global variable" and lacks
the full function signature, parameter list in the heading, and a clear return
shape; update the section to declare it as a function (include its full
signature with optional filter parameter and types), move or add the parameter
list into the heading or immediately under it, and expand the Returns
description to specify the exact array element shape (fields and types) rather
than a generic Object so consumers know what properties each template contains.


- [filter] `Object` - Optional filter object.
- [.type] `string` - Filter by template type (e.g., 'client', 'docs').
- [.stack] `string` - Filter by stack (e.g., 'quarkus', 'express').
- [.protocol] `string` - Filter by protocol (e.g., 'websocket', 'http').
- [.target] `string` - Filter by target language or format (e.g., 'javascript', 'html').

100 changes: 100 additions & 0 deletions markdown/docs/tools/generator/baked-in-templates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
title: "Baked-in Templates"
weight: 55
---

> This is a new concept introduced in generator version 2.8. The number of templates is limited and solution is still in experimental phase. It is not recommended to use them in production. Instead join us to help to improve them with your use cases and your AsyncAPI documents.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Tighten the experimental note and fix grammar

Improve readability; add articles and punctuation.

Apply this diff:

-> This is a new concept introduced in generator version 2.8. The number of templates is limited and solution is still in experimental phase. It is not recommended to use them in production. Instead join us to help to improve them with your use cases and your AsyncAPI documents.
+> This is a new concept introduced in Generator version 2.8. The number of templates is limited, and the solution is still in the experimental phase. We do not recommend using them in production yet. Instead, please join us and help improve them with your use cases and AsyncAPI documents.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
> This is a new concept introduced in generator version 2.8. The number of templates is limited and solution is still in experimental phase. It is not recommended to use them in production. Instead join us to help to improve them with your use cases and your AsyncAPI documents.
> This is a new concept introduced in Generator version 2.8. The number of templates is limited, and the solution is still in the experimental phase. We do not recommend using them in production yet. Instead, please join us and help improve them with your use cases and AsyncAPI documents.
🧰 Tools
🪛 LanguageTool

[grammar] ~6-~6: There might be a mistake here.
Context: ...plates is limited and solution is still in experimental phase. It is not recommend...

(QB_NEW_EN)

🤖 Prompt for AI Agents
In markdown/docs/tools/generator/baked-in-templates.md around line 6, the
experimental note is grammatically awkward and missing articles/punctuation;
rewrite the sentence to be concise and correct (add definite/indefinite
articles, commas and periods) and tighten the cautionary tone—e.g., state that
baked-in templates were introduced in generator v2.8, are limited and
experimental, and recommend against production use while inviting contributors
to help improve them; update the line accordingly for clarity and proper
grammar.


Baked-in templates are official AsyncAPI templates that are **developed, versioned, and shipped directly inside the `generator` repository and exposed with `@asyncapi/generator` library**.

AsyncAPI Generator supports a variety of baked-in template types for generating code, documentation, configs, and SDKs. All templates are managed under the `packages/templates` directory and follow a strict, opinionated directory structure for consistency and ease of maintenance.

> List of baked-in templates: https://github.com/asyncapi/generator/blob/master/apps/generator/lib/templates/BakedInTemplatesList.json

## Supported template types

Templates are grouped by **type**, which must be one of the following:

- `docs` (not yet implemented): Templates that generate documentation
- `client`: Templates that generate clients
- `sdk` (not yet implemented): Template that generate full sdk's
- `config` (not yet implemented): Template that generate configuration files

Comment on lines +18 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Pluralization and capitalization fixes in supported types

Fix verb agreement and SDK capitalization.

Apply this diff:

-- `docs` (not yet implemented): Templates that generate documentation
-- `client`: Templates that generate clients
-- `sdk` (not yet implemented): Template that generate full sdk's
-- `config` (not yet implemented): Template that generate configuration files
+- `docs` (not yet implemented): Templates that generate documentation.
+- `client`: Templates that generate clients.
+- `sdk` (not yet implemented): Templates that generate full SDKs.
+- `config` (not yet implemented): Templates that generate configuration files.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- `docs` (not yet implemented): Templates that generate documentation
- `client`: Templates that generate clients
- `sdk` (not yet implemented): Template that generate full sdk's
- `config` (not yet implemented): Template that generate configuration files
- `docs` (not yet implemented): Templates that generate documentation.
- `client`: Templates that generate clients.
- `sdk` (not yet implemented): Templates that generate full SDKs.
- `config` (not yet implemented): Templates that generate configuration files.
🧰 Tools
🪛 LanguageTool

[grammar] ~18-~18: There might be a mistake here.
Context: ...): Templates that generate documentation - client: Templates that generate clients - `sdk...

(QB_NEW_EN)

🤖 Prompt for AI Agents
In markdown/docs/tools/generator/baked-in-templates.md around lines 18 to 22,
fix pluralization and SDK capitalization: change "Template that generate full
sdk's" to "Templates that generate full SDKs" (remove the apostrophe and
capitalize SDK), and ensure the other entries use plural "Templates"
consistently (e.g., "Template that generate configuration files" -> "Templates
that generate configuration files" and "Template that generate full SDKs" fixed
likewise).

> **Note:**
> The **directory name is always plural** (e.g., `clients`), but the **type recorded in metadata and package name is singular** (e.g., `client`), except for `docs`.

## Template directory structure

### General structure

All template directories must follow this convention:
```
packages/templates/{type}/[protocol]/[target]/[stack]
```

- `type`: One of `docs`, `clients`, `sdks`, or `configs`.
- `protocol`: (Only for `clients` and `sdks`) The protocol this template supports, e.g. `websocket`, `http`, `kafka`.
- `target`: The output language, markup, or format, e.g. `javascript`, `python`, `html`, `yaml`.
- `stack`: (Optional, for `clients` and `sdks`) Used for technology stack, e.g. `express`, `quarkus`.

#### Type-specific rules

- **docs/configs**:
Path must be `type/target` (e.g., `docs/html` or `configs/yaml`).
- **clients/sdks**:
Path must be `type/protocol/target` or `type/protocol/target/stack` (e.g., `clients/websocket/javascript`, `sdks/kafka/java/spring`).

### Required files

Every template directory **must include**:
- `.ageneratorrc`: Generator specific configuration, like for example parameters
- `package.json`: It contains template name. Version information should not be provided as it is versioned together with the generator.

Comment on lines +49 to +52
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Grammar fixes in “Required files”

Hyphenate compound adjectives and clarify sentences.

Apply this diff:

-Every template directory **must include**:
-- `.ageneratorrc`: Generator specific configuration, like for example parameters
-- `package.json`: It contains template name. Version information should not be provided as it is versioned together with the generator.
+Every template directory **must include**:
+- `.ageneratorrc`: Generator-specific configuration (for example, parameters).
+- `package.json`: Contains the template name. Do not include a version; templates are versioned together with the Generator.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Every template directory **must include**:
- `.ageneratorrc`: Generator specific configuration, like for example parameters
- `package.json`: It contains template name. Version information should not be provided as it is versioned together with the generator.
Every template directory **must include**:
- `.ageneratorrc`: Generator-specific configuration (for example, parameters).
- `package.json`: Contains the template name. Do not include a version; templates are versioned together with the Generator.
🧰 Tools
🪛 LanguageTool

[grammar] ~49-~49: There might be a mistake here.
Context: ...ery template directory must include: - .ageneratorrc: Generator specific configuration, like...

(QB_NEW_EN)


[grammar] ~51-~51: There might be a mistake here.
Context: ...example parameters - package.json: It contains template name. Version information shou...

(QB_NEW_EN)

🤖 Prompt for AI Agents
In markdown/docs/tools/generator/baked-in-templates.md around lines 49 to 52,
the "Required files" bullets need grammar and clarity fixes: hyphenate compound
adjectives (change "Generator specific configuration" to "Generator-specific
configuration"), make the package.json sentence clearer and firmer (reword "It
contains template name. Version information should not be provided as it is
versioned together with the generator." to a single clear sentence such as
"package.json contains the template name; do not include version information
because the template is versioned together with the generator."), and ensure
punctuation and capitalization are consistent across the bullet list.

## Metadata and naming conventions

Generator build runs a script that normalize metadata for baked-in templates and their naming:
- Adds/updates metadata in `.ageneratorrc` file. You do not have to maintain it manually.
- Validates/updates template name in `package.json` file of given template. The name always starts with `core-template-` prefix.
- Generates JSON file with list of baked in templates and stores the list inside the generator: `apps/generator/lib/templates/BakedInTemplatesList.json`

#### Example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix heading level increment (MD001)

Change H4 to H3 to avoid skipping a level.

Apply this diff:

-#### Example
+### Example
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#### Example
### Example
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

60-60: Heading levels should only increment by one level at a time
Expected: h3; Actual: h4

(MD001, heading-increment)

🤖 Prompt for AI Agents
In markdown/docs/tools/generator/baked-in-templates.md around line 60, the
heading "#### Example" skips a level; change it from H4 to H3 by replacing "####
Example" with "### Example" so heading levels increment correctly (and scan
nearby headings to ensure no other level skips).


Example information provided for template stored under `packages/templates/clients/websocket/javascript/express`

```yaml
# .ageneratorrc
metadata:
type: client
protocol: websocket
target: javascript
stack: express
```

Package name format: `core-template-client-websocket-javascript-express`

Resulting entry in `apps/generator/lib/templates/BakedInTemplatesList.json`:
```json
{
"name": "core-template-client-websocket-javascript-express",
"type": "client",
"protocol": "websocket",
"target": "javascript",
"stack": "express"
}
```

## How to add a new baked-in template

1. Create the directory in `packages/templates` using the correct structure.
- For a docs template:
`packages/templates/docs/html`
- For a clients template:
`packages/templates/clients/websocket/rust`
1. Add required files:
- `.ageneratorrc` (do not add `generator` config key as it is not needed)
- `package.json`
1. Run generator's build command: `npm run build`

## Templates exposed through generator

Templates that are exposed as part of the generator are transpiled with the `react-sdk` and located in published library under `/lib/templates/bakedInTemplates`. This means that in case of baked-in templates, they are not picked by the generator from `node_modules`. This way the process of generation is faster and more efficient.
Loading
Loading