@redocly/client-generator 0.0.0-snapshot.manual → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/README.md +118 -422
  2. package/lib/config-file.d.ts +2 -2
  3. package/lib/config-file.d.ts.map +1 -1
  4. package/lib/config-file.js +0 -18
  5. package/lib/config-file.js.map +1 -1
  6. package/lib/emitters/client-assembly.d.ts.map +1 -1
  7. package/lib/emitters/client-assembly.js +14 -15
  8. package/lib/emitters/client-assembly.js.map +1 -1
  9. package/lib/emitters/descriptor.d.ts.map +1 -1
  10. package/lib/emitters/descriptor.js +10 -29
  11. package/lib/emitters/descriptor.js.map +1 -1
  12. package/lib/emitters/emit-options.d.ts +16 -20
  13. package/lib/emitters/emit-options.d.ts.map +1 -1
  14. package/lib/emitters/emit-options.js +3 -2
  15. package/lib/emitters/emit-options.js.map +1 -1
  16. package/lib/emitters/faker.d.ts.map +1 -1
  17. package/lib/emitters/faker.js +25 -8
  18. package/lib/emitters/faker.js.map +1 -1
  19. package/lib/emitters/identifier.d.ts +6 -0
  20. package/lib/emitters/identifier.d.ts.map +1 -1
  21. package/lib/emitters/identifier.js +11 -1
  22. package/lib/emitters/identifier.js.map +1 -1
  23. package/lib/emitters/inline-runtime.js +1 -1
  24. package/lib/emitters/inline-runtime.js.map +1 -1
  25. package/lib/emitters/mock.d.ts +2 -2
  26. package/lib/emitters/mock.d.ts.map +1 -1
  27. package/lib/emitters/mock.js +59 -37
  28. package/lib/emitters/mock.js.map +1 -1
  29. package/lib/emitters/operation-aliases.d.ts.map +1 -1
  30. package/lib/emitters/operation-aliases.js +6 -0
  31. package/lib/emitters/operation-aliases.js.map +1 -1
  32. package/lib/emitters/operation-signature.d.ts +1 -0
  33. package/lib/emitters/operation-signature.d.ts.map +1 -1
  34. package/lib/emitters/operation-signature.js +11 -3
  35. package/lib/emitters/operation-signature.js.map +1 -1
  36. package/lib/emitters/operation-types.js +1 -1
  37. package/lib/emitters/operation-types.js.map +1 -1
  38. package/lib/emitters/operations.d.ts +2 -2
  39. package/lib/emitters/operations.d.ts.map +1 -1
  40. package/lib/emitters/operations.js +4 -2
  41. package/lib/emitters/operations.js.map +1 -1
  42. package/lib/emitters/pagination.d.ts +14 -7
  43. package/lib/emitters/pagination.d.ts.map +1 -1
  44. package/lib/emitters/pagination.js +70 -37
  45. package/lib/emitters/pagination.js.map +1 -1
  46. package/lib/emitters/reserved-names.d.ts +5 -0
  47. package/lib/emitters/reserved-names.d.ts.map +1 -0
  48. package/lib/emitters/reserved-names.js +134 -0
  49. package/lib/emitters/reserved-names.js.map +1 -0
  50. package/lib/emitters/runtime-sources.d.ts +6 -6
  51. package/lib/emitters/runtime-sources.js +6 -6
  52. package/lib/emitters/runtime-sources.js.map +1 -1
  53. package/lib/emitters/sample.d.ts +13 -1
  54. package/lib/emitters/sample.d.ts.map +1 -1
  55. package/lib/emitters/sample.js +138 -8
  56. package/lib/emitters/sample.js.map +1 -1
  57. package/lib/emitters/setup-bake.d.ts.map +1 -1
  58. package/lib/emitters/setup-bake.js +15 -1
  59. package/lib/emitters/setup-bake.js.map +1 -1
  60. package/lib/emitters/tanstack-query.d.ts +8 -3
  61. package/lib/emitters/tanstack-query.d.ts.map +1 -1
  62. package/lib/emitters/tanstack-query.js +231 -57
  63. package/lib/emitters/tanstack-query.js.map +1 -1
  64. package/lib/emitters/transformers.d.ts.map +1 -1
  65. package/lib/emitters/transformers.js +118 -36
  66. package/lib/emitters/transformers.js.map +1 -1
  67. package/lib/emitters/ts.d.ts.map +1 -1
  68. package/lib/emitters/ts.js +8 -0
  69. package/lib/emitters/ts.js.map +1 -1
  70. package/lib/emitters/types.d.ts +1 -9
  71. package/lib/emitters/types.d.ts.map +1 -1
  72. package/lib/emitters/types.js +4 -6
  73. package/lib/emitters/types.js.map +1 -1
  74. package/lib/emitters/wrapper-support.d.ts.map +1 -1
  75. package/lib/emitters/wrapper-support.js +2 -0
  76. package/lib/emitters/wrapper-support.js.map +1 -1
  77. package/lib/emitters/zod.d.ts.map +1 -1
  78. package/lib/emitters/zod.js +121 -19
  79. package/lib/emitters/zod.js.map +1 -1
  80. package/lib/generate.d.ts +25 -0
  81. package/lib/generate.d.ts.map +1 -0
  82. package/lib/generate.js +119 -0
  83. package/lib/generate.js.map +1 -0
  84. package/lib/generators/index.d.ts.map +1 -1
  85. package/lib/generators/index.js +9 -2
  86. package/lib/generators/index.js.map +1 -1
  87. package/lib/generators/mock.js +1 -1
  88. package/lib/generators/mock.js.map +1 -1
  89. package/lib/generators/resolve.js +6 -1
  90. package/lib/generators/resolve.js.map +1 -1
  91. package/lib/generators/swr.js +1 -1
  92. package/lib/generators/swr.js.map +1 -1
  93. package/lib/generators/tanstack-query.d.ts +9 -8
  94. package/lib/generators/tanstack-query.d.ts.map +1 -1
  95. package/lib/generators/tanstack-query.js +22 -18
  96. package/lib/generators/tanstack-query.js.map +1 -1
  97. package/lib/generators/transformers.d.ts.map +1 -1
  98. package/lib/generators/transformers.js +4 -2
  99. package/lib/generators/transformers.js.map +1 -1
  100. package/lib/generators/types.d.ts +2 -2
  101. package/lib/generators/types.d.ts.map +1 -1
  102. package/lib/index.d.ts +3 -20
  103. package/lib/index.d.ts.map +1 -1
  104. package/lib/index.js +8 -107
  105. package/lib/index.js.map +1 -1
  106. package/lib/intermediate-representation/build.d.ts.map +1 -1
  107. package/lib/intermediate-representation/build.js +25 -17
  108. package/lib/intermediate-representation/build.js.map +1 -1
  109. package/lib/intermediate-representation/model.d.ts +8 -8
  110. package/lib/intermediate-representation/model.d.ts.map +1 -1
  111. package/lib/intermediate-representation/normalize-swagger2.js +27 -2
  112. package/lib/intermediate-representation/normalize-swagger2.js.map +1 -1
  113. package/lib/intermediate-representation/sanitize-identifiers.d.ts +10 -0
  114. package/lib/intermediate-representation/sanitize-identifiers.d.ts.map +1 -1
  115. package/lib/intermediate-representation/sanitize-identifiers.js +79 -20
  116. package/lib/intermediate-representation/sanitize-identifiers.js.map +1 -1
  117. package/lib/loader.d.ts.map +1 -1
  118. package/lib/loader.js +20 -1
  119. package/lib/loader.js.map +1 -1
  120. package/lib/plugin.d.ts +0 -6
  121. package/lib/plugin.d.ts.map +1 -1
  122. package/lib/plugin.js +7 -8
  123. package/lib/plugin.js.map +1 -1
  124. package/lib/runtime/create-client.d.ts +12 -1
  125. package/lib/runtime/create-client.d.ts.map +1 -1
  126. package/lib/runtime/create-client.js +95 -13
  127. package/lib/runtime/create-client.js.map +1 -1
  128. package/lib/runtime/index.js +2 -2
  129. package/lib/runtime/index.js.map +1 -1
  130. package/lib/runtime/paginate.d.ts +25 -2
  131. package/lib/runtime/paginate.d.ts.map +1 -1
  132. package/lib/runtime/paginate.js +95 -5
  133. package/lib/runtime/paginate.js.map +1 -1
  134. package/lib/runtime/parse.d.ts +5 -1
  135. package/lib/runtime/parse.d.ts.map +1 -1
  136. package/lib/runtime/parse.js +29 -3
  137. package/lib/runtime/parse.js.map +1 -1
  138. package/lib/runtime/send.d.ts +1 -1
  139. package/lib/runtime/send.d.ts.map +1 -1
  140. package/lib/runtime/send.js +2 -2
  141. package/lib/runtime/send.js.map +1 -1
  142. package/lib/runtime/sse.d.ts +1 -0
  143. package/lib/runtime/sse.d.ts.map +1 -1
  144. package/lib/runtime/sse.js +9 -9
  145. package/lib/runtime/sse.js.map +1 -1
  146. package/lib/runtime/types.d.ts +31 -6
  147. package/lib/runtime/types.d.ts.map +1 -1
  148. package/lib/types.d.ts +23 -20
  149. package/lib/types.d.ts.map +1 -1
  150. package/package.json +12 -2
  151. package/lib/config.d.ts +0 -63
  152. package/lib/config.d.ts.map +0 -1
  153. package/lib/config.js +0 -2
  154. package/lib/config.js.map +0 -1
  155. package/lib/emitters/client.d.ts +0 -71
  156. package/lib/emitters/client.d.ts.map +0 -1
  157. package/lib/emitters/client.js +0 -28
  158. package/lib/emitters/client.js.map +0 -1
  159. package/lib/emitters/package-client.d.ts +0 -15
  160. package/lib/emitters/package-client.d.ts.map +0 -1
  161. package/lib/emitters/package-client.js +0 -300
  162. package/lib/emitters/package-client.js.map +0 -1
  163. package/lib/writers/index.d.ts +0 -5
  164. package/lib/writers/index.d.ts.map +0 -1
  165. package/lib/writers/index.js +0 -11
  166. package/lib/writers/index.js.map +0 -1
  167. package/lib/writers/single-file-writer.d.ts +0 -8
  168. package/lib/writers/single-file-writer.d.ts.map +0 -1
  169. package/lib/writers/single-file-writer.js +0 -10
  170. package/lib/writers/single-file-writer.js.map +0 -1
  171. package/lib/writers/split-writer.d.ts +0 -14
  172. package/lib/writers/split-writer.d.ts.map +0 -1
  173. package/lib/writers/split-writer.js +0 -23
  174. package/lib/writers/split-writer.js.map +0 -1
  175. package/lib/writers/types.d.ts +0 -31
  176. package/lib/writers/types.d.ts.map +0 -1
  177. package/lib/writers/types.js +0 -2
  178. package/lib/writers/types.js.map +0 -1
  179. package/lib/writers/util.d.ts +0 -14
  180. package/lib/writers/util.d.ts.map +0 -1
  181. package/lib/writers/util.js +0 -14
  182. package/lib/writers/util.js.map +0 -1
package/README.md CHANGED
@@ -1,501 +1,197 @@
1
1
  # @redocly/client-generator
2
2
 
3
- > ⚠️ **Experimental.** This package and the client generator are released as **experimental**: the generated output, options, and the plugin API may change in any minor release until it is declared stable (see [ADR-0013](./docs/adr/0013-experimental-status.md)).
3
+ Generate a typed TypeScript client from an OpenAPI description.
4
+ See https://github.com/Redocly/redocly-cli for the full project.
5
+
6
+ > [!WARNING]
7
+ > This package is experimental: the generated output, options, and the plugin API may change in any minor release until it is declared stable (see [ADR-0013](./docs/adr/0013-experimental-status.md)).
4
8
  > Pin your version if you depend on the output, and expect to regenerate when you upgrade.
5
9
  > Feedback is very welcome while we stabilize it.
6
10
 
7
- Generate a typed TypeScript client (inline types + `fetch` runtime) from an OpenAPI description.
8
- The emitted client has **zero runtime dependencies** by default it uses only web-standard APIs (`fetch`, `AbortController`, `URLSearchParams`, …), so it runs in browsers, Node ≥ 18, Bun, Deno, and edge runtimes.
9
- Opt in to `runtime: 'package'` to import the runtime from this package instead, so engine fixes arrive via `npm update` without regenerating.
10
- Code is produced through the TypeScript compiler AST (not string templates), so output is correct by construction; `typescript` is the only (peer) dependency.
11
-
12
- This package is the engine behind the **`redocly generate-client`** command.
13
- To run it from the command line, install [`@redocly/cli`](https://github.com/Redocly/redocly-cli) and see the [`generate-client` command reference](https://redocly.com/docs/cli/commands/generate-client).
14
- The rest of this README covers using the package **programmatically**.
15
-
16
- ## Features
17
-
18
- - **Broad input** — OpenAPI **3.0, 3.1, and 3.2.0**, plus **Swagger 2.0** (normalized to 3.x before generation)
19
- `api` is a file path or URL.
20
- - **Zero-dependency client** (the default `inline` runtime) built via the TS AST, with `typescript` as the only peer dep
21
- - **Output modes** — `single` or `split` (schema types in a sibling `<stem>.schemas.ts`) (`outputMode`)
22
- - **Runtime distribution** (`runtime`) — `inline` (default, self-contained) or `package`: the client imports its runtime from `@redocly/client-generator` (pure-data operation descriptors + a build-time version-skew guard), so engine fixes arrive via `npm update` — no regeneration
23
- - **Both call styles, always** — a typed `client` instance (grouped-args methods, **per-instance configuration and credentials** via `createClient(OPERATIONS, { auth, serverUrl, … })`) plus free-function operations bound to it
24
- - **Argument styles** — `flat` positional args or a `grouped` `vars` object (`argsStyle`)
25
- - **Rich types** — inline types for every schema:
26
- - string enums as unions or runtime `const` objects (`enumStyle`)
27
- - **discriminated-union `is<Member>()` type guards** `<Op>Result` / `Error` / `Params` / `Body` / `Headers` / `Variables` aliases (collision-suppressed)
28
- - validation keywords surfaced as JSDoc
29
- - `dateType: 'Date'`
30
- - **typed `multipart/form-data` bodies** (object fields, binary → `Blob`) auto-serialized to `FormData`
31
- - **Runtime** — a typed `ClientConfig` (`serverUrl`, headers, `fetch` swap, hooks) applied via `configure()`:
32
- - **composable middleware** (`onRequest`/`onResponse`/`onError`) whose `ctx.operation.id`/`path`/`tags` are the spec's **literal unions** — a misspelled operation id fails compilation
33
- - **opt-in, abort-aware retries** with backoff, jitter, `Retry-After`, and a custom `retryOn`
34
- - per-call response decoding (`parseAs`)
35
- - OpenAPI **query-serialization styles**
36
- - `errorMode: 'result'` for a discriminated `{ data, error, response }`
37
- - a minification-safe `OPERATIONS` metadata map
38
- - **Auth** — Basic / Bearer / apiKey (header, query, cookie) setters from `securitySchemes`, async token providers, and per-instance credentials via `ClientConfig.auth`
39
- - **Server-Sent Events** — `text/event-stream` operations as typed async iterators with auto-reconnect; payloads typed from OpenAPI 3.2 `itemSchema`
40
- - **Auto-pagination** — declared via the `pagination` option (a statically verified convention rule + per-operation overrides) or the spec's `x-pagination` extension (`cursor`/`offset`/`page` styles); paginated operations keep their one-shot call and gain `.pages()`/`.items()` async iterators, item types resolved from the response schema at generate time
41
- - **Generators** (`generators`) — `sdk` (default), `zod`, `tanstack-query` (React/Vue/Svelte/Solid), `swr`, `transformers`, `mock` (MSW handlers + baked or `faker` data), and a [custom-generator plugin API](#custom-generators)
42
- - **Hardened** — document-derived names coerced to safe unique identifiers, comment text escaped, and a bounded SSE reader
43
-
44
- No add-on generator adds a dependency to the emitted client; its peer library is needed only in your app.
45
-
46
- ## Use programmatically
47
-
48
- `generateClient(options)` is the API behind the CLI command — it loads the spec, builds the client, and writes the files:
11
+ The generated client uses only web-standard APIs (`fetch`, `AbortController`, `URLSearchParams`), so by default it is a single self-contained file with zero runtime dependencies that runs in browsers, Node ≥ 18, Bun, Deno, and edge runtimes.
12
+ (Running the generator itself requires the Node version in this package's `engines` field.)
13
+ Code is produced through the TypeScript compiler AST, not string templates; `typescript` is the only peer dependency optional, needed only when you run generation, and it must be 6.x there (TypeScript 7's native compiler has no compiler API).
14
+ Apps that only consume a package-runtime client don't need it at all, and can compile the generated code with any TypeScript, including 7.
49
15
 
50
- ```ts
51
- import { generateClient } from '@redocly/client-generator';
16
+ This package is the engine behind the [`generate-client` command](https://redocly.com/docs/cli/commands/generate-client) — install [`@redocly/cli`](https://www.npmjs.com/package/@redocly/cli) to run it from the command line or `redocly.yaml`.
17
+ How to use the generated client — auth, middleware, retries, pagination, Server-Sent Events, and the add-on generators (`zod`, `tanstack-query`, `swr`, `mock`, `transformers`) — is documented in [Use the generated client](https://redocly.com/docs/cli/guides/use-generated-client).
18
+ This README covers using the package programmatically.
52
19
 
53
- const result = await generateClient({
54
- api: 'openapi.yaml', // file path or URL
55
- output: 'src/client.ts', // entry file; the .schemas.ts sibling derives from it in split mode
56
- outputMode: 'single', // 'single' | 'split'
57
- runtime: 'inline', // 'inline' | 'package' (import the runtime from this package)
58
- argsStyle: 'flat', // 'flat' | 'grouped'
59
- errorMode: 'throw', // 'throw' | 'result'
60
- dateType: 'string', // 'string' | 'Date' (pair 'Date' with the 'transformers' generator)
61
- enumStyle: 'const-object', // 'const-object' | 'union'
62
- generators: ['sdk'], // see "Generators" below
63
- // serverUrl, queryFramework, mockData, mockSeed, pagination, customGenerators are also accepted
64
- });
20
+ ## Basic usage
65
21
 
66
- console.log(`Wrote ${result.files.length} file(s), ${result.bytes} bytes.`);
67
- ```
68
-
69
- For type-safe authoring of a standalone options object, annotate it with `satisfies Config`:
22
+ ### Generate a client
70
23
 
71
24
  ```ts
72
- import { generateClient, type Config } from '@redocly/client-generator';
25
+ import { generateClient } from '@redocly/client-generator';
73
26
 
74
- const options = {
75
- api: './openapi.yaml',
27
+ const result = await generateClient({
28
+ api: './openapi.yaml', // file path or URL; OpenAPI 3.0/3.1/3.2 or Swagger 2.0
76
29
  output: './src/api/client.ts',
77
30
  generators: ['sdk', 'zod'],
78
- } satisfies Config;
79
-
80
- await generateClient(options);
81
- ```
82
-
83
- To inspect the output without writing to disk, the lower-level `collectGeneratedFiles(model, opts)` returns the files in memory (see `src/index.ts`).
84
-
85
- ## Using the generated client
86
-
87
- ```ts
88
- import { configure, use, getOrderById, listMenuItems, setBearer } from './client.ts';
89
-
90
- // Optional: global config (base URL, headers, fetch swap, hooks, retry).
91
- configure({ retry: { retries: 3 } });
92
-
93
- // Composable middleware for cross-cutting concerns (logging, tracing, auth refresh).
94
- use({
95
- onRequest: (ctx) => {
96
- ctx.headers['X-Request-Id'] = crypto.randomUUID();
97
- },
98
31
  });
99
32
 
100
- // Auth helpers are generated from the spec's `securitySchemes`.
101
- setBearer(token);
102
-
103
- const menu = await listMenuItems({ limit: 10 });
104
- const order = await getOrderById('ord_01khr487f7qm7p44xn427m43vb');
105
-
106
- // Per-call options (AbortSignal, retry override) go in the trailing `init` arg.
107
- const live = await listMenuItems({ limit: 10 }, { signal: controller.signal });
108
- ```
109
-
110
- Each operation's trailing `init` argument is `RequestOptions` (`RequestInit` plus an optional per-call `retry` override and a `parseAs` reader).
111
- Retry is opt-in and abort-aware.
112
- A custom `retryOn(ctx)` predicate can branch on `ctx.error` (transport failure) or `ctx.response` (HTTP status / body) and opt a `POST` in.
113
-
114
- By default a response body is decoded by negotiating from its `Content-Type`.
115
- Pass `parseAs` in `init` to force a reader — `'json'`, `'text'`, `'blob'`, `'arrayBuffer'`, `'formData'`, `'stream'` (the raw `ReadableStream`), or `'auto'` (the default):
116
-
117
- ```ts
118
- const stream = await getMenuItemPhoto('prd_…', { parseAs: 'stream' }); // ReadableStream
33
+ console.log(`Wrote ${result.files.length} file(s), ${result.bytes} bytes.`);
119
34
  ```
120
35
 
121
- `parseAs` is a **runtime override only** it does not change the operation's static return type.
122
- Forcing a reader that disagrees with the schema is the caller's responsibility.
36
+ Every `redocly.yaml` `client` option is accepted with the same name and default see the [`client` configuration reference](https://redocly.com/docs/cli/configuration/reference/client).
37
+ For type-safe authoring of a standalone options object, annotate it with `satisfies GenerateClientOptions`.
123
38
 
124
- Query parameters honor their OpenAPI serialization style.
125
- The default (`form` + `explode: true`) repeats array values.
126
- Declare `style` / `explode` / `allowReserved` on a parameter to get `form`+`explode:false` (`key=a,b`), `spaceDelimited` (`key=a%20b`), `pipeDelimited` (`key=a|b`), `deepObject`, or reserved-char passthrough.
39
+ ### Build extra client instances
127
40
 
128
- A setter is generated for each injectable scheme — `setBearer` (HTTP `bearer` / OAuth2), `setBasicAuth(username, password)` (HTTP `basic`), and `setApiKey…` for `apiKey` schemes in header, query, or cookie — and each operation sends the credentials its `security` requires.
129
- Each setter is instance-bound sugar over the exported client (`export const setBearer = client.auth.bearer;`); credentials are **per instance** (`ClientConfig.auth`), so independent instances built with `createClient(OPERATIONS, { auth })` carry independent credentials — the generated module exports `createClient` in both runtimes (see the [`multi-instance` example](./examples/multi-instance)).
130
- Bearer/apiKey credentials accept a `TokenProvider` (a string or a possibly-async function resolved per request) for refresh-token flows:
41
+ The generated module exports its operation descriptors, so an app can build additional instances with independent configuration and credentials over the same generated code:
131
42
 
132
43
  ```ts
133
- import { setBearer, setBasicAuth, setApiKey } from './client.ts';
44
+ import { createClient } from '@redocly/client-generator';
45
+ import { OPERATIONS, type Ops } from './client.ts';
134
46
 
135
- setBearer(async () => await getFreshAccessToken()); // resolved before each authed call
136
- setBasicAuth('alice', 's3cr3t'); // `Authorization: Basic <base64>`
137
- setApiKey('my-api-key'); // header / query / cookie, per the scheme's `in`
47
+ const internal = createClient<Ops>(OPERATIONS, {
48
+ serverUrl: 'https://api.example.com',
49
+ auth: { basic: { username: 'svc', password: 's3cr3t' } },
50
+ });
138
51
  ```
139
52
 
140
- With `argsStyle: 'grouped'`, inputs are bundled into a single `vars` object (typed as the operation's `<Op>Variables`) instead of positional arguments, while `init` stays the trailing argument:
53
+ With `runtime: 'package'` the generated client also imports its whole engine from this package (instead of embedding it), so engine fixes arrive via `npm update` install this package as a regular dependency of the consuming app.
141
54
 
142
- ```ts
143
- const order = await getOrderById({ orderId: 'ord_01khr487f7qm7p44xn427m43vb' });
144
- ```
55
+ ### Write a custom generator
145
56
 
146
- With `errorMode: 'result'`, operations don't throw on non-2xx.
147
- Each operation returns a discriminated `{ data, error, response }` whose `error` is typed from the spec's 4xx/5xx bodies (the `<Op>Error` union).
148
- On success `error` is `undefined`; the HTTP status is always on `response.status`:
57
+ A custom generator reads the same API model the built-ins consume, runs in the same pass, and returns files.
58
+ Build real TypeScript with the emit toolkit from `@redocly/client-generator/generate` the same `ts.factory` + printer the built-in generators use, so the schema→type mapping matches the sdk's exactly:
149
59
 
150
60
  ```ts
151
- const { data, error, response } = await getOrderById('ord_01khr487f7qm7p44xn427m43vb');
152
- if (error)
153
- console.error(response.status, error); // `error` is the typed body
154
- else console.log(data.id); // `data` is the success body
155
- ```
156
-
157
- Transport/abort failures still throw in both modes.
158
-
159
- The client also exports an `OPERATIONS` map (operationId → `{ method, path, tags }`) plus the `OperationId` / `OperationPath` / `OperationTag` / `OperationMetadata` types.
160
- The string-literal keys, path templates, and tags survive minification, so they're the stable handle for cache/query keys, tracing span names, and request logging:
161
-
162
- ```ts
163
- import { OPERATIONS, getOrderById } from './client.ts';
164
-
165
- const queryKey = [OPERATIONS.getOrderById.path, orderId]; // "/orders/{orderId}"
166
- ```
167
-
168
- ### Customizing requests and responses
61
+ // response-map-generator.ts
62
+ import { defineGenerator } from '@redocly/client-generator';
63
+ import { printStatements, schemaToTypeNode, ts } from '@redocly/client-generator/generate';
169
64
 
170
- You shape requests and responses from your own code — never by editing the generated client, so changes survive regeneration.
171
- Middleware (`use(...)` — sugar for `client.use(...)`, so it registers on that instance) hooks the request lifecycle, and each `RequestContext` carries the operation's identity so you can target by operationId or tag instead of brittle URL matching.
172
- `onRequest` may mutate `ctx.url` / `ctx.method` / `ctx.headers` **and `ctx.body`**; `onResponse` may observe or replace the `Response`:
65
+ const { factory } = ts;
173
66
 
174
- ```ts
175
- import { configure, use, listMenuItems } from './client.ts';
176
-
177
- // A custom transport — proxy, instrument, or (here) swap fetch entirely.
178
- configure({ fetch: myFetch });
179
-
180
- use({
181
- onRequest: (ctx) => {
182
- // Target specific operations by identity, not URL shape.
183
- if (ctx.operation.id === 'createOrder' || ctx.operation.tags.includes('Orders')) {
184
- ctx.headers['X-Idempotency-Key'] = crypto.randomUUID();
185
- (ctx.body as { source?: string }).source = 'web'; // body edits are sent
186
- }
187
- },
188
- onResponse: (response, ctx) => {
189
- console.debug(ctx.operation.id, response.status);
67
+ export default defineGenerator({
68
+ name: 'response-map',
69
+ requires: ['sdk'],
70
+ run({ model, outputPath }) {
71
+ // One `ResponseShapes` entry per operation with a JSON success body.
72
+ const members = model.services
73
+ .flatMap((service) => service.operations)
74
+ .flatMap((op) => {
75
+ const success = op.successResponses.find((r) => r.contentType.includes('json'));
76
+ if (!success) return [];
77
+ return [
78
+ factory.createPropertySignature(
79
+ undefined,
80
+ op.name,
81
+ undefined,
82
+ schemaToTypeNode(success.schema)
83
+ ),
84
+ ];
85
+ });
86
+ const alias = factory.createTypeAliasDeclaration(
87
+ [factory.createModifier(ts.SyntaxKind.ExportKeyword)],
88
+ 'ResponseShapes',
89
+ undefined,
90
+ factory.createTypeLiteralNode(members)
91
+ );
92
+ return [
93
+ { path: outputPath.replace(/\.ts$/, '.responses.ts'), content: printStatements([alias]) },
94
+ ];
190
95
  },
191
96
  });
192
-
193
- // A header for one call only goes in the trailing RequestOptions.
194
- await listMenuItems({}, { headers: { 'X-Request-Id': '42' } });
195
- ```
196
-
197
- `ctx.operation` is `{ id, path, tags }` — the operationId, the path template (`{param}` placeholders intact), and the operation's tags. All three are **typed literal unions** (`OperationId` / `OperationPath` / `OperationTag`, exported alongside the `OPERATIONS` map), so `ctx.operation.id === '…'` and `ctx.operation.tags.includes('…')` autocomplete and reject typos at compile time.
198
- See the [`configure-and-middleware` example](../../tests/e2e/generate-client/examples/configure-and-middleware) for a runnable end-to-end version, and [ADR-0014](./docs/adr/0014-request-response-customization.md) for the rationale.
199
-
200
- ### Baking defaults into a published SDK
201
-
202
- The customization above is composed by the **consumer**. If you instead **publish an SDK** and want those defaults already active for _your_ users, bake them in at generation time with `--setup <file>`. The setup module imports its contract from `@redocly/client-generator` (so it resolves and is unit-testable before the client is generated) and returns a `defineClientSetup({ config, middleware })`:
203
-
204
- ```ts
205
- // client-setup.ts
206
- import { defineClientSetup, type RequestContext } from '@redocly/client-generator';
207
-
208
- export default defineClientSetup({
209
- config: { serverUrl: 'https://api.acme.com', retry: { retries: 3 } },
210
- middleware: [
211
- {
212
- onRequest: (ctx: RequestContext) => {
213
- ctx.headers['X-Acme-SDK'] = '1.4.0';
214
- if (ctx.operation.tags.includes('Orders'))
215
- ctx.headers['X-Idempotency-Key'] = crypto.randomUUID();
216
- },
217
- },
218
- ],
219
- });
220
- ```
221
-
222
- ```sh
223
- redocly generate-client openapi.yaml --output src/api/client.ts --setup ./client-setup.ts
224
- ```
225
-
226
- The generator bakes the `config`/`middleware` into the generated client, so the published package applies them on import — your users call operations with no setup of their own, and can still override (their `configure`/`use` run after the baked ones; config layers spec defaults → baked setup → app `configure()`, middleware composes). Works across both output modes and both runtimes. A setup file may import **only** from `@redocly/client-generator`, so it never adds a dependency to the client.
227
-
228
- See the [`baked-setup` example](./examples/baked-setup) and [ADR-0015](./docs/adr/0015-publisher-setup-bake-in.md).
229
-
230
- ## Testing the generated client
231
-
232
- The client is plain `fetch` code, so you test it like any HTTP code — there is no special harness.
233
-
234
- **In Node** (scripts, Vitest/Jest) there is **no CORS** — point it at any reachable API and call it:
235
-
236
- ```ts
237
- import { configure, listMenuItems } from './client.ts';
238
-
239
- configure({ serverUrl: 'https://api.example.com' });
240
- const items = await listMenuItems(); // resolves or throws ApiError
241
97
  ```
242
98
 
243
- **In the browser, CORS applies** and it's the **target API's** policy, not the client's. Two things
244
- to watch:
245
-
246
- - The API must allow your origin (`Access-Control-Allow-Origin`).
247
- - Any **custom request header** you add (e.g. `X-Request-Id` via `use({ onRequest })` middleware)
248
- triggers a **CORS preflight**, so the API must also list that header in `Access-Control-Allow-Headers`
249
- — otherwise the browser blocks the request and `fetch` throws `TypeError: Failed to fetch`. If the
250
- API doesn't allow it, drop the header, use a dev proxy (e.g. Vite's `server.proxy`), or mock the API.
251
-
252
- **Without a backend (recommended for tests and local dev), use MSW mocks.** Add `mock` to
253
- `generators` to emit an MSW handler module; requests are intercepted in-process, so there's **no real
254
- network and no CORS** — the same client runs unchanged against the mocks:
255
-
256
- ```ts
257
- import { setupServer } from 'msw/node'; // or 'msw/browser' for the browser
258
- import { handlers } from './client.mocks.ts';
259
-
260
- const server = setupServer(...handlers);
261
- beforeAll(() => server.listen());
262
- afterAll(() => server.close());
263
-
264
- // now calls to the generated client resolve from the mocks
265
- ```
266
-
267
- The repo's [`examples/`](./examples) are runnable end-to-end: `npm install && npm run dev` in an
268
- example directory serves it on `http://localhost:5173` against the live demo API (a CORS-enabled
269
- `GET`), and `examples/mock` shows the MSW-backed flow.
270
-
271
- ## Generators
272
-
273
- `generators` (default `['sdk']`) selects which files to emit.
274
- The `sdk` client is dependency-free with the default `inline` runtime; each add-on lands in its own sibling file and needs its peer library only in your app.
275
- Every generator works with both runtimes and both output modes.
276
-
277
- ### Runtime validation with Zod
99
+ For a trivial artifact, returning a plain string as `content` works too no toolkit required.
100
+ Select the generator in `generators` by import specifier (a path or a package name), or register it inline via `customGenerators` and select it by `name`.
101
+ A custom generator never adds dependencies to the generated client.
102
+ See [Custom generators](https://redocly.com/docs/cli/guides/customize-client-generation#custom-generators).
278
103
 
279
- `generators: ['sdk', 'zod']` emits a standalone `<output>.zod.ts` module of [Zod](https://zod.dev) schemas (one `export const <Name>Schema` per schema).
280
- The generated client never imports Zod; only the `*.zod.ts` module does.
281
- Install Zod in your app as a peer — any `zod` `^3.23 || ^4`:
104
+ ### Pre-configure a published SDK
282
105
 
283
- ```ts
284
- import { z } from 'zod';
285
- import type { Pet } from './client.ts';
286
- import { PetSchema } from './client.zod.ts';
106
+ The `setup` option takes a module that default-exports a `{ config, middleware }` object (optionally wrapped in `defineClientSetup` for editor typing); its defaults are included in the generated client so a published SDK ships them built in, and consumers can still override.
107
+ See [Publisher defaults](https://redocly.com/docs/cli/guides/customize-client-generation#publisher-defaults).
287
108
 
288
- const pet: Pet = PetSchema.parse(await res.json()); // z.infer<typeof PetSchema> === Pet
289
- ```
109
+ ## API
290
110
 
291
- Schemas carry the validation refinements stable across Zod 3.23 and 4 (`.min`/`.max`, `.gt`/`.lt`, `.int`, `.regex`).
292
- Refs become `z.lazy(() => …)` so recursive schemas work.
293
- Format helpers (`.email`/`.uuid`/`.url`) are not emitted, since they diverge between Zod 3 and 4.
111
+ ### `generateClient`
294
112
 
295
- The module also emits `operationSchemas` (request/response validators keyed by operationId) and the `zodValidation` middleware:
113
+ Loads the description, builds the client, and writes the files.
296
114
 
297
115
  ```ts
298
- import { use } from './client.ts';
299
- import { zodValidation } from './client.zod.ts';
116
+ async function generateClient(options: GenerateClientOptions): Promise<GenerateClientResult>;
300
117
 
301
- use(zodValidation()); // request bodies validated before the wire; JSON responses after it
118
+ type GenerateClientResult = {
119
+ outputPath: string; // the `output` anchor path (the entry file in multi-file modes)
120
+ bytes: number; // total bytes written
121
+ files: Array<{ path: string; bytes: number }>; // every file written to disk
122
+ };
302
123
  ```
303
124
 
304
- A mismatch throws `ZodValidationError` (`operationId`, `direction`, zod `issues`); payloads are never mutated.
125
+ `GenerateClientOptions` is the [`Config` type](./src/config.ts) (`api` and `output` required; `outputMode`, `runtime`, `importExt`, `argsStyle`, `errorMode`, `dateType`, `serverUrl`, `mockData`, `mockSeed`, `generators`, `customGenerators`, `setup`, `pagination` optional) plus an optional resolved Redocly `config` used to load the description.
305
126
 
306
- ### TanStack Query
127
+ ### `collectGeneratedFiles`
307
128
 
308
- `generators: ['sdk', 'tanstack-query']` emits a standalone `<output>.tanstack.ts` module of [TanStack Query](https://tanstack.com/query) v5 factories wrapping the sdk operations.
309
- Each query op (`GET`/`HEAD`) gets a `<op>QueryKey`/`<op>Options` factory (returning `queryOptions`).
310
- Each mutation gets a `<op>Mutation` factory (returning `mutationKey`/`mutationFn`):
129
+ Runs the configured generators against a built model and returns the files in memory, without writing to disk.
130
+ Imported from `@redocly/client-generator/generate` the generation-time entry; the package root stays runtime-only so package-mode clients never load the generator stack:
311
131
 
312
132
  ```ts
313
- import { useQuery, useMutation } from '@tanstack/react-query';
314
- import { getPetOptions, createPetMutation } from './client.tanstack.ts';
315
-
316
- const { data } = useQuery(getPetOptions({ id }));
317
- const { mutate } = useMutation(createPetMutation());
133
+ function collectGeneratedFiles(
134
+ model: ApiModel,
135
+ options: {
136
+ outputPath: string;
137
+ outputMode: OutputMode;
138
+ emit: EmitOptions;
139
+ generators: string[];
140
+ registry?: Map<string, GeneratorDescriptor>; // defaults to the built-ins
141
+ }
142
+ ): GeneratedFile[];
318
143
  ```
319
144
 
320
- Only the `*.tanstack.ts` module imports TanStack Query; install it as a peer — any `@tanstack/react-query` `^5`.
321
- The factories wrap the **throw-mode** sdk (the default), since TanStack's `queryFn` is expected to throw on error.
322
-
323
- **Framework** — TanStack's `queryOptions`/`mutationOptions` API is identical across adapters, so the emitted module is byte-identical across frameworks; only the import specifier differs.
324
- Set `queryFramework` to `react` (default), `vue`, `svelte`, or `solid` and install the matching adapter (`@tanstack/<framework>-query`, any `^5`).
325
-
326
- ### SWR
145
+ ### `defineGenerator`
327
146
 
328
- `generators: ['sdk', 'swr']` emits a standalone `<output>.swr.ts` module of [SWR](https://swr.vercel.app) hooks.
329
- Each query op (`GET`/`HEAD`) gets a `<op>Key` tuple factory + a `use<Op>(vars, init?)` hook over `useSWR`; each mutation gets a `use<Op>()` hook over `useSWRMutation`:
147
+ Authors a custom generator (`{ name, run }` plus optional `requires`/`errorModes`/`dateTypes`/`runtimes` compatibility metadata, validated up front):
330
148
 
331
149
  ```ts
332
- import { useGetPetById, useCreatePet } from './client.swr.ts';
333
-
334
- const { data } = useGetPetById({ id });
335
- const { trigger } = useCreatePet();
336
- await trigger({ body: { name: 'Rex' } });
150
+ function defineGenerator(generator: CustomGenerator): CustomGenerator;
337
151
  ```
338
152
 
339
- Only the `*.swr.ts` module imports SWR (`swr` for queries, `swr/mutation` for mutations); install it as a peerany `swr` `^2`.
340
- The hooks wrap the **throw-mode** sdk functions.
153
+ The `@redocly/client-generator/generate` entry also exports the emit toolkit the built-ins use (`ts`, `printStatements`, `parseStatements`, `operationSignature`, `schemaToTypeNode`, `pascalCase`, ), and the package root exports the IR types, so a custom generator emits TypeScript exactly as the first-party ones do see the [`ast-toolkit-generator` example](https://github.com/Redocly/redocly-cli/tree/main/tests/e2e/generate-client/examples/ast-toolkit-generator).
341
154
 
342
- ### Date transformers
155
+ ### `defineClientSetup`
343
156
 
344
- By default `date-time`/`date` fields are typed `string`.
345
- Set `dateType: 'Date'` to type them as `Date`, and add `'transformers'` to `generators` to emit a `<output>.transformers.ts` module of `transform<Name>` functions that convert wire ISO strings to `Date` at runtime:
157
+ Optional typing helper for authoring a publisher setup module — a plain default-exported `{ config, middleware }` object works too, with no imports:
346
158
 
347
159
  ```ts
348
- import { getPet } from './client.ts';
349
- import { transformPet } from './client.transformers.ts';
350
-
351
- const pet = transformPet(await getPet(id)); // pet.createdAt is now a Date
160
+ function defineClientSetup(setup: {
161
+ config?: ClientConfig;
162
+ middleware?: Middleware[];
163
+ }): ClientSetup;
352
164
  ```
353
165
 
354
- The transformers import only the schema **types**, so they add no dependency to the client (`Date` is a web standard).
355
- `int64` → `bigint` is deferred; without `dateType: 'Date'` the date fields stay `string`.
166
+ A setup module may import only from `@redocly/client-generator`, so it never adds a dependency to the client (the import is stripped at generation time).
356
167
 
357
- ### MSW mocks
168
+ ### `createClient`
358
169
 
359
- `generators: ['sdk', 'mock']` emits a standalone `<output>.mocks.ts` module of [MSW](https://mswjs.io) v2 request handlers and `create<Schema>(overrides?)` data factories.
360
- Each handler intercepts its operation's method + path and responds with a fixture baked from the spec (prefers `example`/`default`; `format: binary` → `new Blob([])`.
361
- Recursive schemas terminate at the cycle with an empty array/record).
362
- Each `create<Schema>` factory builds the same default object and merges `overrides`, so factories double as test builders.
363
- Install MSW as a dev dependency — `msw` `^2`:
170
+ The runtime factory that `runtime: 'package'` clients import, also usable directly to build extra instances over generated descriptors (see [Basic usage](#build-extra-client-instances)):
364
171
 
365
172
  ```ts
366
- // test setup (Node)
367
- import { setupServer } from 'msw/node';
368
- import { handlers } from './client.mocks';
369
-
370
- const server = setupServer(...handlers);
371
- beforeAll(() => server.listen());
372
- afterEach(() => server.resetHandlers());
373
- afterAll(() => server.close());
374
-
375
- // override a single factory for one case
376
- import { createMenuItem } from './client.mocks';
377
- const special = createMenuItem({ name: 'Cold Brew', price: 499 });
173
+ function createClient<Ops>(
174
+ operations: Record<string, OperationDescriptor>,
175
+ config?: ClientConfig
176
+ ): Client<Ops>;
378
177
  ```
379
178
 
380
- **Realistic data with faker** — mock data is **baked** by default (deterministic literals, no extra dependency).
381
- Set `mockData: 'faker'` to emit [`@faker-js/faker`](https://fakerjs.dev) calls for realistic data, and `mockSeed: <n>` to pin faker's PRNG so the data is reproducible.
382
- Factory signatures are identical in both modes; faker mode makes `@faker-js/faker` (`^9`) a dev dependency of your app (the client itself gains no dependency).
383
-
384
- ## Custom generators
385
-
386
- Need an output the built-ins don't ship — validators in another library, a UI permissions map, mocks in your test runner's format, an SDK in your house style?
387
- Write a **custom generator**: it reads the same OpenAPI-derived model the built-ins do, runs in the same pass, and its output never drifts from the spec.
388
-
389
- ```ts
390
- // route-map-generator.ts
391
- import { defineGenerator } from '@redocly/client-generator';
392
-
393
- export default defineGenerator({
394
- name: 'route-map',
395
- requires: ['sdk'],
396
- run({ model, outputPath }) {
397
- const routes = model.services
398
- .flatMap((service) => service.operations)
399
- .map((op) => ` ${op.name}: '${op.method.toUpperCase()} ${op.path}',`)
400
- .join('\n');
401
- return [
402
- {
403
- path: outputPath.replace(/\.ts$/, '.routes.ts'),
404
- content: `export const routes = {\n${routes}\n} as const;\n`,
405
- },
406
- ];
407
- },
408
- });
409
- ```
410
-
411
- Select it in `generators` by import specifier (a path or package), or register it inline and select it by `name`:
412
-
413
- ```ts
414
- import { generateClient } from '@redocly/client-generator';
415
- import routeMap from './tools/route-map-generator.ts';
416
-
417
- await generateClient({
418
- api: './openapi.yaml',
419
- output: './src/api/client.ts',
420
- customGenerators: [routeMap], // register…
421
- generators: ['sdk', 'route-map'], // …then select by name (or pass './tools/route-map-generator.ts')
422
- });
423
- ```
424
-
425
- `@redocly/client-generator` also exports the IR types and the codegen toolkit the built-ins use (`ts`, `printStatements`, `operationSignature`, `schemaToTypeNode`, `pascalCase`, …).
426
- A generator declares the same `requires`/`errorModes`/`dateTypes`/`runtimes` contract, validated up front.
427
- A custom generator never adds dependencies to the generated client.
428
- See `examples/custom-generator` for a runnable example.
429
-
430
- ## Server-Sent Events (streaming)
431
-
432
- An operation whose `2xx` response declares `text/event-stream` is generated — with no option — as a typed **async-generator** client method plus the matching free function.
433
- Each event's `data` is typed from the OpenAPI 3.2 `itemSchema` (falling back to the media `schema`, then `string`):
434
-
435
- ```ts
436
- import { streamMessages } from './client.ts';
437
-
438
- for await (const ev of streamMessages()) {
439
- console.log(ev.id, ev.data.text); // ev: ServerSentEvent<Message>
440
- }
441
- ```
442
-
443
- The stream **auto-reconnects** on a dropped connection, resuming via the `Last-Event-ID` header (backoff: server `retry:` → `reconnectDelay` → 1s, exponential with jitter, capped at 30s).
444
- Tune or opt out per call (`{ reconnect: false }` / `{ reconnectDelay: 500 }`), and `break` or pass an `AbortSignal` to stop early — both end the iterator cleanly (no throw).
445
- SSE operations always throw `ApiError` on an initial non-2xx and never return the `result`-mode shape.
446
-
447
- ## Auto-pagination
448
-
449
- Pagination is **declared, never guessed** — in the `pagination` option (or `redocly.yaml` `client.pagination`; the spec's `x-pagination` operation extension takes the same fields).
450
- A convention rule applies to every operation it **structurally fits** (the advance param is a declared query parameter of the right type; the JSON pointers resolve in the JSON success-response schema, `items` landing on an array); an explicit rule (an `operations` override or `x-pagination`) that doesn't fit fails generation.
451
- Precedence per operation: `operations[id]` > `x-pagination` > convention; `exclude` wins over all.
452
-
453
- ```ts
454
- await generateClient({
455
- api: './openapi.yaml',
456
- output: './src/api/client.ts',
457
- pagination: {
458
- style: 'cursor', // 'cursor' | 'offset' | 'page'
459
- cursorParam: 'cursor', // the query param that receives the cursor
460
- nextCursor: '/nextCursor', // JSON pointer to the next cursor in the response
461
- items: '/orders', // JSON pointer to the page's item array
462
- },
463
- });
464
- ```
465
-
466
- Each paginated operation keeps its one-shot call and gains `.pages(args?, init?)` / `.items(args?, init?)` async iterators (the flat function too — note its iterators take the **grouped** args shape while the function itself stays positional).
467
- Item types are resolved from the response schema at generate time — no runtime reflection:
468
-
469
- ```ts
470
- import { client, listOrders } from './client.ts';
471
-
472
- for await (const order of client.listOrders.items({ params: { limit: 20 } })) {
473
- console.log(order.id); // `order` is typed `Order`
474
- }
475
-
476
- await listOrders({ limit: 20 }); // flat one-shot: positional
477
- for await (const page of listOrders.pages({ params: { cursor: 'c2' } })) {
478
- // resume from a saved cursor; pass `{ signal }` as `init` to abort mid-iteration
479
- }
480
- ```
481
-
482
- `cursor` style stops when `nextCursor` is absent/`null`/empty (and throws if the cursor doesn't advance); `offset`/`page` styles stop on an empty page.
483
- Iteration is error-mode-agnostic: a failed page throws `ApiError` even on `errorMode: 'result'` clients, where `.pages()` yields raw pages (not `{ data, error, response }` envelopes).
484
- Inline output embeds the pagination module only when some operation paginates; `runtime: 'package'` clients receive pagination improvements via `npm update`.
485
-
486
179
  ## Examples
487
180
 
488
- Runnable examples live in [`examples/`](../../tests/e2e/generate-client/examples): `zero-install-quickstart`, `fetch-functions`, `configure-and-middleware`, `baked-setup`, `sse-streaming`, `zod`, `tanstack-query`, `mock`, `custom-generator`, `programmatic`, `vendored-edge`, `package-runtime` (`runtime: 'package'` engine fixes via `npm update`), `multi-instance` (per-tenant `createClient` instances over one generated module), `pagination` and `custom-pagination` (the declared convention vs. a hand-written helper), and `nested-facade` (a custom generator grouping operations by tag).
181
+ Runnable examples from a zero-install quickstart to middleware, publisher setup, SSE streaming, pagination, custom generators, and the package runtime — live in [`tests/e2e/generate-client/examples`](https://github.com/Redocly/redocly-cli/tree/main/tests/e2e/generate-client/examples).
489
182
  Each is a standalone Vite app with a checked-in, drift-checked generated client.
490
183
 
491
184
  ## Documentation
492
185
 
493
- - [`generate-client` command reference](https://redocly.com/docs/cli/commands/generate-client) — CLI usage, every flag, and `redocly.yaml` configuration.
186
+ - [`generate-client` command reference](https://redocly.com/docs/cli/commands/generate-client) — CLI usage, flags, and `redocly.yaml` configuration.
187
+ - [Use the generated client](https://redocly.com/docs/cli/guides/use-generated-client) — the runtime API and the add-on generators.
188
+ - [Customize client generation](https://redocly.com/docs/cli/guides/customize-client-generation) — publisher defaults and custom generators.
494
189
  - [`ARCHITECTURE.md`](./ARCHITECTURE.md) and the [ADRs](./docs/adr/) — how the package is built and why.
495
190
 
496
191
  ## Development
497
192
 
498
- This package is part of the Redocly CLI monorepo. Run all commands from the repo root:
193
+ This package is part of the Redocly CLI monorepo.
194
+ Run all commands from the repo root:
499
195
 
500
196
  ```sh
501
197
  npm run compile # build this package
@@ -503,4 +199,4 @@ npm run unit # unit tests (this package is held at 100% cover
503
199
  VITEST_SUITE=e2e npx vitest run tests/e2e/generate-client/ # behavioral e2e
504
200
  ```
505
201
 
506
- The client runtime lives in `src/runtime/` (real, unit-testable modules; package mode imports them, inline mode embeds them via the generated `src/emitters/runtime-sources.ts` snapshot and the `src/emitters/inline-runtime.ts` assembler), the structural emitters in `src/emitters/`, the IR in `src/intermediate-representation/`, the generators in `src/generators/`, and the file-layout writers in `src/writers/`.
202
+ The client runtime lives in `src/runtime/` (real, unit-testable modules; package mode imports them, inline mode embeds them), the structural emitters in `src/emitters/`, the IR in `src/intermediate-representation/`, the generators in `src/generators/`, and the file-layout writers in `src/writers/`.