Skip to content

Commit d0c2cd3

Browse files
committed
docs: improve AsyncAPI CLI documentation with extended options and usage details
1 parent ad89ba1 commit d0c2cd3

2 files changed

Lines changed: 54 additions & 16 deletions

File tree

website/docs/codegen/CLI/asyncapi.mdx

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ sidebar_label: AsyncAPI
55

66
# AsyncAPI mode (`qraft asyncapi`)
77

8-
`qraft asyncapi` is the AsyncAPI-focused mode of `@qraft/cli`.
9-
10-
It uses AsyncAPI-compatible plugins and currently supports built-in generation with:
11-
12-
- `asyncapi-typescript``@qraft/asyncapi-typescript-plugin`
8+
`qraft asyncapi` is the AsyncAPI-focused mode of the unified `@qraft/cli` package.
9+
It generates TypeScript schema types from AsyncAPI documents using AsyncAPI plugins.
1310

1411
## Installation
1512

@@ -19,21 +16,61 @@ npm install -D @qraft/cli @qraft/asyncapi-typescript-plugin
1916

2017
## Usage
2118

19+
The command below generates AsyncAPI TypeScript schema types into the `src/events` directory:
20+
2221
```bash npm2yarn
2322
npx qraft asyncapi --plugin asyncapi-typescript ./asyncapi.yaml --output-dir src/events
2423
```
2524

26-
## Required options
25+
## Options
2726

28-
- **`-o <path>, --output-dir <path>`** — output directory for generated files.
27+
### Required
2928

30-
## Plugin selection
29+
- **`-o <path>, --output-dir <path>`**: Specify where to output generated files.
30+
- Example: `--output-dir src/events`
3131

32-
`qraft asyncapi` requires explicit plugin selection:
32+
### Optional
3333

34-
```bash npm2yarn
35-
npx qraft asyncapi --plugin asyncapi-typescript ./asyncapi.yaml -o ./src/events
36-
```
34+
- **`-c, --clean`**: Clean the output directory before generation.
35+
- **`--file-header <string>`**: Add a custom header to each generated file, useful for disabling linting rules or adding file comments.
36+
- Example: `--file-header '/* eslint-disable */'`
37+
- **`--redocly [config]`**: Use the Redocly configuration to generate multiple API clients. If the `[config]` parameter is not specified, the default Redocly configuration will be used: `[redocly.yaml | redocly.yml | .redocly.yaml | .redocly.yml]`.
38+
- Examples:
39+
- `--redocly`
40+
- `--redocly ./my-redocly-config.yaml`
41+
- `qraft asyncapi events --redocly`
42+
- For more information about this option, use the command: `--redocly-help` or [read the docs](/codegen/CLI/redocly-config.mdx).
43+
- **`--plugin <name_1> --plugin <name_2>`**: Generator plugins to be used. (choices: `asyncapi-typescript`)
44+
- Example: `--plugin asyncapi-typescript`
45+
- **`-h, --help`**: Display help for the command.
46+
47+
## Plugin System
48+
49+
The following plugin is currently supported:
50+
51+
- `asyncapi-typescript` - Generates TypeScript types from an AsyncAPI Document.
52+
53+
:::tip
54+
Plugin must be provided with the `--plugin <name>` option.
55+
:::
56+
57+
### `--plugin asyncapi-typescript` options
58+
59+
- **`--asyncapi-types-file-name <path>`**: AsyncAPI Schema types file name, e.g., `schema.d.ts` (default: `schema.ts`).
60+
- Must end with `.ts` or `.d.ts`.
61+
- Must not include path separators (`/` or `\`).
62+
- Must not start with `.`.
63+
- **`--enum`**: Export true TypeScript enums instead of unions.
64+
- **`--enum-values`**: Export enum values as arrays.
65+
- **`--dedupe-enums`**: Dedupe enum types when `--enum` is set.
66+
- **`-t, --export-type`**: Export top-level `type` instead of `interface`.
67+
- **`--immutable`**: Generate readonly types.
68+
- **`--additional-properties`**: Treat schema objects as if `additionalProperties: true` is set.
69+
- **`--empty-objects-unknown`**: Generate `unknown` instead of `Record<string, never>` for empty objects.
70+
- **`--default-non-nullable`**: Set to `false` to ignore default values when generating non-nullable types.
71+
- **`--properties-required-by-default`**: Treat schema objects as if `required` is set to all properties by default.
72+
- **`--alphabetize`**: Sort object keys alphabetically.
73+
- **`--exclude-deprecated`**: Exclude deprecated fields from types.
3774

3875
## Redocly config support
3976

@@ -48,6 +85,7 @@ apis:
4885
asyncapi-typescript: true
4986
output-dir: src/events
5087
clean: true
88+
asyncapi-types-file-name: asyncapi.ts
5189
```
5290
5391
Then run:

website/docs/codegen/CLI/cli.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ sidebar_label: CLI overview
99

1010
It supports **two generation modes**:
1111

12-
- **[OpenAPI mode](/codegen/CLI/openapi-cli.mdx)** (`qraft openapi`) — generates code from OpenAPI documents with OpenAPI plugins.
13-
- **[AsyncAPI mode](/codegen/CLI/asyncapi-cli.mdx)** (`qraft asyncapi`) — enables generation from AsyncAPI documents with AsyncAPI plugins.
12+
- **[OpenAPI mode](/codegen/CLI/openapi.mdx)** (`qraft openapi`) — generates code from OpenAPI documents with OpenAPI plugins.
13+
- **[AsyncAPI mode](/codegen/CLI/asyncapi.mdx)** (`qraft asyncapi`) — enables generation from AsyncAPI documents with AsyncAPI plugins.
1414

1515
This lets you use one CLI package and one binary (`qraft`) for both OpenAPI and AsyncAPI schemas.
1616

1717
## Detailed docs
1818

19-
- [OpenAPI mode (`qraft openapi`)](/codegen/CLI/openapi-cli.mdx)
20-
- [AsyncAPI mode (`qraft asyncapi`)](/codegen/CLI/asyncapi-cli.mdx)
19+
- [OpenAPI mode (`qraft openapi`)](/codegen/CLI/openapi.mdx)
20+
- [AsyncAPI mode (`qraft asyncapi`)](/codegen/CLI/asyncapi.mdx)
2121
- [Redocly config support](/codegen/CLI/redocly-config.mdx)

0 commit comments

Comments
 (0)