You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added an experimental `generate-client` command that generates a typed, zero-dependency TypeScript client from an OpenAPI description — auth, retries, middleware, typed SSE streaming, pagination, and multipart included — plus optional companion generators for Zod validation, TanStack Query and SWR hooks, MSW mocks, and date transformers.
8
+
See the [`generate-client` command reference](https://redocly.com/docs/cli/commands/generate-client) and the [Use the generated client](https://redocly.com/docs/cli/guides/use-generated-client) guide.
Copy file name to clipboardExpand all lines: .claude/skills/redocly-cli/SKILL.md
+26-1Lines changed: 26 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
name: redocly-cli
3
-
description: Redocly CLI usage for OpenAPI, AsyncAPI, Arazzo, and Overlay descriptions. Use when linting an API description, bundling or splitting multi-file descriptions, joining several APIs into one, transforming a description with decorators, building or previewing API docs, testing a live API with respect to its description.
3
+
description: Redocly CLI usage for OpenAPI, AsyncAPI, Arazzo, and Overlay descriptions. Use when linting an API description, bundling or splitting multi-file descriptions, joining several APIs into one, transforming a description with decorators, building or previewing API docs, testing a live API with respect to its description, generating a TypeScript client from an OpenAPI description.
4
4
---
5
5
6
6
# Redocly CLI usage
@@ -38,6 +38,7 @@ Install: `npm i @redocly/cli@latest`, or run without installing: `npx @redocly/c
38
38
|`preview`| Local preview of a Redocly project |
39
39
|`respect`| Run API tests described in an Arazzo description against a live API |
40
40
|`generate-arazzo`| Scaffold an Arazzo description from an OpenAPI description |
41
+
|`generate-client`| Generate a typed, zero-dependency TypeScript client [experimental]|
41
42
|`login` / `logout` / `push` / `push-status`| Authenticate and push to the Redocly platform (Reunite) |
42
43
43
44
Exit codes: `0` success, `1` problems found or execution failed, `2` configuration error.
@@ -118,6 +119,29 @@ rules:
118
119
my-plugin/operation-id-not-test: error
119
120
```
120
121
122
+
## Generate a TypeScript client
123
+
124
+
`generate-client <api> --output client.ts`turns an OpenAPI description into a typed client — one self-contained file with zero runtime dependencies (auth, retries, middleware, typed SSE, pagination included).
125
+
Configure it durably under a `client` block in `redocly.yaml` instead of flags:
126
+
127
+
```yaml
128
+
client:
129
+
generators: [sdk, zod] # add-ons: tanstack-query, swr, mock, transformers, or a plugin path
130
+
outputMode: split
131
+
pagination: # config-only, no CLI flag
132
+
style: cursor
133
+
cursorParam: after
134
+
nextCursor: /page/endCursor
135
+
items: /items
136
+
apis:
137
+
my-api:
138
+
root: ./openapi/openapi.yaml
139
+
clientOutput: ./src/api/client.ts
140
+
```
141
+
142
+
With `apis.<name>.clientOutput` set, a bare `redocly generate-client` generates every opted-in API.
143
+
An API's own `client` block replaces the top-level one wholesale — repeat the shared fields in it.
144
+
121
145
## Test a live API
122
146
123
147
`respect`executes an [Arazzo](https://spec.openapis.org/arazzo/latest.html) description as a test suite against a running API, asserting real responses match the description.
@@ -139,6 +163,7 @@ Start from `generate-arazzo <openapi>` to scaffold the workflows, then refine th
139
163
- `respect`currently covers only synchronous HTTP flow.
140
164
- Any `redocly.yaml` in the working directory configures every command — a stray one changes lint results silently.
141
165
- `--extends`on the command line sets the base ruleset for that run; useful for a quick `--extends=spec` conformance check.
166
+
- `generate-client`needs the `typescript` package (6.x) available at generation time; the generated client itself compiles with any TypeScript, including 7.
Inline types plus a typed client instance and one async function per operation, with auth, opt-in abort-aware retries, middleware, and typed Server-Sent Events.
154
+
The same command can also emit Zod schemas, TanStack Query / SWR hooks, MSW mocks, and more via `--generator`.
155
+
For detailed information, read the [`generate-client` docs](./docs/@v2/commands/generate-client.md).
156
+
142
157
### Transform an OpenAPI description
143
158
144
159
If your OpenAPI description isn't everything you hoped it would be, enhance it with the Redocly [decorators](https://redocly.com/docs/cli/decorators) feature.
0 commit comments