Skip to content

Commit e4a775e

Browse files
committed
docs: add comprehensive generate command reference (Resolves #2125)
1 parent deabb5b commit e4a775e

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

docs/commands/generate.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
3+
# asyncapi generate
4+
5+
Generates code from AsyncAPI documents using AsyncAPI Generator templates.
6+
7+
## Description
8+
9+
The `asyncapi generate` command generates code from AsyncAPI documents using AsyncAPI Generator templates. This allows developers to quickly implement API clients, servers, documentation, and more based on their AsyncAPI specifications.
10+
11+
The command supports three main subcommands:
12+
13+
1. **Generate from template**: `asyncapi generate fromTemplate <asyncapi-spec> <template>`
14+
2. **Generate models**: `asyncapi generate models <asyncapi-spec>`
15+
3. **Generate client**: `asyncapi generate client <language> <asyncapi-spec>`
16+
17+
## Common Options
18+
19+
### For all subcommands:
20+
21+
- `--output, -o <directory>`: Specify the output directory for generated code
22+
- `--install`: Install the template and its dependencies
23+
- `--force-write`: Force writing of generated files even if the output directory is not empty
24+
- `--param, -p <key=value>`: Additional parameters to pass to the template
25+
- `--map-base-url`: Maps all schema references from base URL to local folder
26+
- `--registry-url`: Specifies the URL of the private registry for fetching templates
27+
- `--registry-auth`: The registry username and password encoded with base64
28+
- `--registry-token`: The npm registry authentication token
29+
- `--no-interactive`: Disable interactive mode and run with provided flags
30+
- `--debug`: Enable more specific errors in the console
31+
32+
## Common Flags
33+
34+
| Flag | Description |
35+
|------|-------------|
36+
| `--output, -o` | Directory where generated code will be saved |
37+
| `--install` | Install the template and its dependencies |
38+
| `--force-write` | Force writing of generated files |
39+
| `--param, -p` | Additional parameters to pass to the template |
40+
| `--map-base-url` | Maps all schema references from base URL to local folder |
41+
| `--registry-url` | Specifies the URL of the private registry |
42+
| `--registry-auth` | The registry username and password encoded with base64 |
43+
| `--registry-token` | The npm registry authentication token |
44+
| `--no-interactive` | Disable interactive mode |
45+
| `--debug` | Enable more specific errors |
46+
47+
## Examples
48+
49+
1. Generate models from AsyncAPI specification:
50+
```bash
51+
asyncapi generate models spec.yaml
52+
```
53+
54+
2. Generate client for a specific language:
55+
```bash
56+
asyncapi generate client javascript spec.yaml --param version=1.0.0 --output ./client
57+
```
58+
59+
3. Generate code from template with specific parameters:
60+
```bash
61+
asyncapi generate fromTemplate spec.yaml @asyncapi/html-template --param version=1.0.0 --output ./docs
62+
```
63+
64+
4. Generate code with force-write option:
65+
```bash
66+
asyncapi generate fromTemplate spec.yaml @asyncapi/html-template --force-write --output ./generated
67+
```
68+
69+
5. Generate code with registry configuration:
70+
```bash
71+
asyncapi generate fromTemplate spec.yaml @asyncapi/html-template --registry-url https://custom-registry.com --registry-token mytoken
72+
```
73+

0 commit comments

Comments
 (0)