zvyappy 0.0.0-stage → 0.14.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 (170) hide show
  1. package/.claude-plugin/marketplace.json +11 -0
  2. package/LICENSE +21 -0
  3. package/README.md +733 -2
  4. package/README.npm.md +732 -0
  5. package/dist/cli/commands/cache.d.ts +2 -0
  6. package/dist/cli/commands/config.d.ts +2 -0
  7. package/dist/cli/commands/generate.d.ts +2 -0
  8. package/dist/cli/commands/info.d.ts +2 -0
  9. package/dist/cli/commands/migrate.d.ts +2 -0
  10. package/dist/cli/commands/versions.d.ts +2 -0
  11. package/dist/cli/index.d.ts +2 -0
  12. package/dist/cli/presets.d.ts +7 -0
  13. package/dist/cli/start.d.ts +1 -0
  14. package/dist/cli.d.ts +2 -0
  15. package/dist/cli.js +516 -0
  16. package/dist/client/index.d.ts +2 -0
  17. package/dist/client/index.js +1 -0
  18. package/dist/client/is-zvyappy-error.d.ts +7 -0
  19. package/dist/config.d.ts +3 -0
  20. package/dist/constants/banner.d.ts +1 -0
  21. package/dist/constants/index.d.ts +2 -0
  22. package/dist/constants/meta.d.ts +21 -0
  23. package/dist/index.d.ts +5 -0
  24. package/dist/index.js +274 -0
  25. package/dist/libs/auth.d.ts +10 -0
  26. package/dist/libs/duration.d.ts +17 -0
  27. package/dist/libs/error.d.ts +1 -0
  28. package/dist/libs/index.d.ts +12 -0
  29. package/dist/libs/logger/index.d.ts +1 -0
  30. package/dist/libs/logger/logger.d.ts +36 -0
  31. package/dist/libs/operations/dedupe.d.ts +11 -0
  32. package/dist/libs/operations/endpoints.d.ts +2 -0
  33. package/dist/libs/operations/filter.d.ts +3 -0
  34. package/dist/libs/operations/format.d.ts +2 -0
  35. package/dist/libs/operations/index.d.ts +4 -0
  36. package/dist/libs/operations/rename.d.ts +3 -0
  37. package/dist/libs/string/apply-naming.d.ts +3 -0
  38. package/dist/libs/string/capitalize.d.ts +1 -0
  39. package/dist/libs/string/case-fns.d.ts +6 -0
  40. package/dist/libs/string/identifier.d.ts +38 -0
  41. package/dist/libs/string/index.d.ts +8 -0
  42. package/dist/libs/string/to-camel-case.d.ts +1 -0
  43. package/dist/libs/string/to-kebab-case.d.ts +1 -0
  44. package/dist/libs/string/to-pascal-case.d.ts +13 -0
  45. package/dist/libs/string/to-snake-case.d.ts +1 -0
  46. package/dist/libs/validation/index.d.ts +1 -0
  47. package/dist/libs/validation/validate-config.d.ts +11 -0
  48. package/dist/models/config.d.ts +384 -0
  49. package/dist/models/defaults.d.ts +65 -0
  50. package/dist/models/index.d.ts +12 -0
  51. package/dist/models/ir.d.ts +109 -0
  52. package/dist/models/plugin.d.ts +361 -0
  53. package/dist/models/swagger.d.ts +6 -0
  54. package/dist/models/versioning.d.ts +18 -0
  55. package/dist/plugins/faker.d.ts +10 -0
  56. package/dist/plugins/index.d.ts +12 -0
  57. package/dist/plugins/mcp.d.ts +11 -0
  58. package/dist/plugins/msw.d.ts +10 -0
  59. package/dist/plugins/playwright.d.ts +14 -0
  60. package/dist/plugins/requests.d.ts +10 -0
  61. package/dist/plugins/rhf.d.ts +12 -0
  62. package/dist/plugins/swr.d.ts +15 -0
  63. package/dist/plugins/tanstack.d.ts +13 -0
  64. package/dist/plugins/typescript.d.ts +10 -0
  65. package/dist/plugins/valibot.d.ts +11 -0
  66. package/dist/plugins/yup.d.ts +11 -0
  67. package/dist/plugins/zod.d.ts +11 -0
  68. package/dist/services/adapters/adapters.d.ts +29 -0
  69. package/dist/services/adapters/get-adapter.d.ts +3 -0
  70. package/dist/services/adapters/index.d.ts +3 -0
  71. package/dist/services/cache/fetch.d.ts +12 -0
  72. package/dist/services/cache/index.d.ts +27 -0
  73. package/dist/services/cache/storage.d.ts +63 -0
  74. package/dist/services/codegen/common/build-args.d.ts +11 -0
  75. package/dist/services/codegen/common/generate-error-types.d.ts +3 -0
  76. package/dist/services/codegen/common/generate-property.d.ts +2 -0
  77. package/dist/services/codegen/common/generate-type-value.d.ts +14 -0
  78. package/dist/services/codegen/common/get-args.d.ts +9 -0
  79. package/dist/services/codegen/common/get-base-url.d.ts +3 -0
  80. package/dist/services/codegen/common/get-client-import.d.ts +5 -0
  81. package/dist/services/codegen/common/get-error-config.d.ts +13 -0
  82. package/dist/services/codegen/common/get-function-name.d.ts +10 -0
  83. package/dist/services/codegen/common/get-plugin-import.d.ts +25 -0
  84. package/dist/services/codegen/common/get-response-type.d.ts +9 -0
  85. package/dist/services/codegen/common/get-types-import.d.ts +7 -0
  86. package/dist/services/codegen/common/get-url.d.ts +6 -0
  87. package/dist/services/codegen/common/jsdoc.d.ts +8 -0
  88. package/dist/services/codegen/common/needs-query-helper.d.ts +14 -0
  89. package/dist/services/codegen/common/query-formats.d.ts +17 -0
  90. package/dist/services/codegen/common/schema-graph.d.ts +32 -0
  91. package/dist/services/codegen/common/zvyappy-error.d.ts +14 -0
  92. package/dist/services/codegen/faker/generate-faker-factory.d.ts +2 -0
  93. package/dist/services/codegen/faker/value.d.ts +33 -0
  94. package/dist/services/codegen/index.d.ts +35 -0
  95. package/dist/services/codegen/mcp/generate-mcp-tool.d.ts +4 -0
  96. package/dist/services/codegen/mcp/input-schema.d.ts +13 -0
  97. package/dist/services/codegen/msw/generate-msw-handler.d.ts +3 -0
  98. package/dist/services/codegen/msw/utils.d.ts +7 -0
  99. package/dist/services/codegen/playwright/generate-fixture.d.ts +26 -0
  100. package/dist/services/codegen/playwright/generate-method.d.ts +15 -0
  101. package/dist/services/codegen/playwright/helpers.d.ts +24 -0
  102. package/dist/services/codegen/playwright/index.d.ts +7 -0
  103. package/dist/services/codegen/playwright/utils.d.ts +49 -0
  104. package/dist/services/codegen/requests/build-error-handling.d.ts +5 -0
  105. package/dist/services/codegen/requests/build-multipart.d.ts +2 -0
  106. package/dist/services/codegen/requests/build-raw-response.d.ts +4 -0
  107. package/dist/services/codegen/requests/generate-function.d.ts +2 -0
  108. package/dist/services/codegen/requests/return-lines.d.ts +13 -0
  109. package/dist/services/codegen/swr/generate-mutation.d.ts +2 -0
  110. package/dist/services/codegen/swr/generate-query.d.ts +2 -0
  111. package/dist/services/codegen/swr/generate-swr-hooks.d.ts +3 -0
  112. package/dist/services/codegen/swr/query-keys.d.ts +6 -0
  113. package/dist/services/codegen/tanstack/build-imports.d.ts +7 -0
  114. package/dist/services/codegen/tanstack/framework.d.ts +18 -0
  115. package/dist/services/codegen/tanstack/generate-mutation.d.ts +3 -0
  116. package/dist/services/codegen/tanstack/generate-query.d.ts +15 -0
  117. package/dist/services/codegen/tanstack/generate-tanstack-hooks.d.ts +6 -0
  118. package/dist/services/codegen/tanstack/query-keys.d.ts +6 -0
  119. package/dist/services/codegen/typescript/generate-composition.d.ts +2 -0
  120. package/dist/services/codegen/typescript/generate-enum-schema.d.ts +2 -0
  121. package/dist/services/codegen/typescript/generate-object.d.ts +2 -0
  122. package/dist/services/codegen/typescript/generate-schema.d.ts +2 -0
  123. package/dist/services/codegen/typescript/inline-enum-names.d.ts +16 -0
  124. package/dist/services/codegen/valibot/enum.d.ts +3 -0
  125. package/dist/services/codegen/valibot/generate-valibot-schema.d.ts +6 -0
  126. package/dist/services/codegen/valibot/primitives.d.ts +4 -0
  127. package/dist/services/codegen/valibot/value.d.ts +3 -0
  128. package/dist/services/codegen/yup/enum.d.ts +3 -0
  129. package/dist/services/codegen/yup/generate-yup-schema.d.ts +6 -0
  130. package/dist/services/codegen/yup/primitives.d.ts +4 -0
  131. package/dist/services/codegen/yup/value.d.ts +3 -0
  132. package/dist/services/codegen/zod/generate-zod-enum.d.ts +3 -0
  133. package/dist/services/codegen/zod/generate-zod-schema.d.ts +21 -0
  134. package/dist/services/codegen/zod/zod-primitives.d.ts +4 -0
  135. package/dist/services/migrate/hey-api/load-hey-api-config.d.ts +2 -0
  136. package/dist/services/migrate/hey-api/migrate-hey-api.d.ts +4 -0
  137. package/dist/services/migrate/index.d.ts +9 -0
  138. package/dist/services/migrate/kubb/load-kubb-config.d.ts +2 -0
  139. package/dist/services/migrate/kubb/migrate-kubb.d.ts +4 -0
  140. package/dist/services/migrate/load-module.d.ts +8 -0
  141. package/dist/services/migrate/orval/load-orval-config.d.ts +7 -0
  142. package/dist/services/migrate/orval/migrate-orval.d.ts +4 -0
  143. package/dist/services/migrate/paths.d.ts +14 -0
  144. package/dist/services/migrate/plugins.d.ts +21 -0
  145. package/dist/services/migrate/render-config.d.ts +2 -0
  146. package/dist/services/migrate/types.d.ts +35 -0
  147. package/dist/services/parser/index.d.ts +4 -0
  148. package/dist/services/parser/ir/build-body.d.ts +3 -0
  149. package/dist/services/parser/ir/build-errors.d.ts +3 -0
  150. package/dist/services/parser/ir/build-ir.d.ts +3 -0
  151. package/dist/services/parser/ir/build-params.d.ts +3 -0
  152. package/dist/services/parser/ir/build-response.d.ts +3 -0
  153. package/dist/services/parser/ir/build-schema.d.ts +60 -0
  154. package/dist/services/parser/ir/index.d.ts +2 -0
  155. package/dist/services/parser/load.d.ts +8 -0
  156. package/dist/services/parser/swagger/bundle-external.d.ts +19 -0
  157. package/dist/services/parser/swagger/index.d.ts +1 -0
  158. package/dist/services/parser/swagger/load-spec.d.ts +2 -0
  159. package/dist/services/versioning/index.d.ts +2 -0
  160. package/dist/services/versioning/snapshot.d.ts +10 -0
  161. package/dist/services/versioning/storage.d.ts +41 -0
  162. package/dist/services/writer/groups.d.ts +11 -0
  163. package/dist/services/writer/index-builder.d.ts +6 -0
  164. package/dist/services/writer/index.d.ts +6 -0
  165. package/dist/services/writer/write-fn.d.ts +13 -0
  166. package/package.json +171 -4
  167. package/skills/zvyappy/SKILL.md +143 -0
  168. package/skills/zvyappy/cache.md +62 -0
  169. package/skills/zvyappy/custom-plugin.md +111 -0
  170. package/skills/zvyappy/plugins.md +313 -0
package/README.md CHANGED
@@ -1,3 +1,734 @@
1
- # Temporary Holding Version
1
+ # zvyappy
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **OpenAPI code generator for TypeScript with a plugin system.** Point it at an OpenAPI spec and it writes the typed code your app needs to talk to that API — types, request functions, validation schemas, data-fetching hooks, form resolvers, mock data, mock handlers, end-to-end test clients and an MCP server — from one config file and one command.
4
+
5
+ ```bash
6
+ npm install -D zvyappy
7
+ npx zvyappy generate # or the short alias: npx zvy generate
8
+ ```
9
+
10
+ - **One spec, many outputs.** Each output is a plugin; enable only what you use.
11
+ - **Compiles under `--strict`.** Generated code is type-checked against real-world specs, including the awkward ones — non-identifier names, dotted schema names, recursive schemas, `default` responses, bodiless responses.
12
+ - **Five HTTP clients.** `fetch` (no dependency), `axios`, `ky`, `ofetch` or `wretch` — using your own configured instance.
13
+ - **Typed errors.** Every request throws a typed `ZvyappyError` whose body is a union of the error responses the spec declares.
14
+ - **Works with your stack.** TanStack Query (React, Vue, Svelte, Solid), SWR (React, Vue), Zod, Valibot, Yup, React Hook Form, Faker, MSW, Playwright, MCP.
15
+ - **Migrates from orval, kubb and Hey API** with `zvyappy migrate`.
16
+
17
+ Full documentation: **https://apig-docs.vercel.app**
18
+
19
+ ---
20
+
21
+ ## Contents
22
+
23
+ - [Quick start](#quick-start)
24
+ - [What gets generated](#what-gets-generated)
25
+ - [Using the generated code](#using-the-generated-code)
26
+ - [Configuration](#configuration)
27
+ - [Plugins](#plugins)
28
+ - [CLI](#cli)
29
+ - [Migrating from orval, kubb or Hey API](#migrating-from-orval-kubb-or-hey-api)
30
+ - [Renamed from `@travjek/apig`](#renamed-from-travjekapig)
31
+ - [Supported OpenAPI features](#supported-openapi-features)
32
+ - [Rules and plugin compatibility](#rules-and-plugin-compatibility)
33
+ - [Writing a custom plugin](#writing-a-custom-plugin)
34
+ - [For AI assistants](#for-ai-assistants)
35
+
36
+ ---
37
+
38
+ ## Quick start
39
+
40
+ **1. Install** zvyappy as a dev dependency, plus the runtime library of each plugin you use (see [Plugins](#plugins)):
41
+
42
+ ```bash
43
+ npm install -D zvyappy
44
+ npm install @tanstack/react-query zod # only if you use tanstackQuery() and zod()
45
+ ```
46
+
47
+ **2. Create `zvyappy.config.ts`** in the project root — by hand, with `npx zvyappy start` (interactive wizard), or with `npx zvyappy config --preset react`:
48
+
49
+ ```ts
50
+ // zvyappy.config.ts
51
+ import { defineConfig, typescript, requests, tanstackQuery } from 'zvyappy';
52
+
53
+ export default defineConfig({
54
+ input: './openapi.json', // file path (JSON or YAML) or URL
55
+ output: './src/api',
56
+ plugins: [typescript(), requests(), tanstackQuery()],
57
+ });
58
+ ```
59
+
60
+ **3. Generate:**
61
+
62
+ ```bash
63
+ npx zvyappy generate # once
64
+ npx zvyappy generate --watch # regenerate when the spec or config changes
65
+ ```
66
+
67
+ **4. Use it:**
68
+
69
+ ```tsx
70
+ import { useListPetsQuery, useCreatePetMutation } from './api';
71
+
72
+ function Pets() {
73
+ const { data, error } = useListPetsQuery({ status: 'available' });
74
+ const createPet = useCreatePetMutation();
75
+
76
+ if (error) return <p>Failed with HTTP {error.status}</p>;
77
+ return (
78
+ <>
79
+ <ul>{data?.items.map((pet) => <li key={pet.id}>{pet.name}</li>)}</ul>
80
+ <button onClick={() => createPet.mutate({ body: { name: 'Rex', status: 'available' } })}>
81
+ Add
82
+ </button>
83
+ </>
84
+ );
85
+ }
86
+ ```
87
+
88
+ ---
89
+
90
+ ## What gets generated
91
+
92
+ Each plugin writes one file into `output` (default `.zvyappy/generated`). The output directory is cleaned before every run unless `output.clean` is `false` — don't put hand-written code in it.
93
+
94
+ | File | Written by | Contents |
95
+ |------|-----------|----------|
96
+ | `types.ts` | `typescript()` | A `type` (or `interface`) per schema, plus enums |
97
+ | `requests.ts` | `requests()` | One async function per operation, plus `<Op>Errors` unions |
98
+ | `config.ts` | `requests()` / `playwright()` | Shared runtime helpers: `ZvyappyError`, `parseErrorBody`, `toQuery`, `ZvyappyResponse` |
99
+ | `zod.ts` / `valibot.ts` / `yup.ts` | validation plugins | A schema per component (`PetSchema`) and, by default, the types |
100
+ | `tanstack.ts` | `tanstackQuery()` | Query keys, `queryOptions`, query/mutation hooks |
101
+ | `query-keys.ts` | `tanstackQuery({ queryKeysStyle: 'object' })` | One shared `queryKeys` object |
102
+ | `swr.ts` (+ `swr-keys.ts`) | `swr()` | SWR hooks and keys |
103
+ | `rhf.ts` | `rhf()` | One resolver per schema |
104
+ | `faker.ts` | `faker()` | One `generate<Schema>()` factory per schema |
105
+ | `msw.ts` | `msw()` | `handlers` array for Mock Service Worker |
106
+ | `playwright.ts` | `playwright()` | `createApiClient(ctx)`, `ApiClient` type and a `test.extend()` fixture |
107
+ | `mcp.ts` | `mcp()` | A runnable MCP stdio server, one tool per operation |
108
+ | `endpoints.ts` | `endpointsMap: true` | `ENDPOINTS` map of operation → path, `EndpointKey` type |
109
+ | `index.ts` | always (unless `index: false`) | Named re-exports of everything above |
110
+
111
+ **Where the types live.** A validation plugin (`zod()`, `valibot()`, `yup()`) emits the TypeScript types itself by default (`withTypes: true`), and `types.ts` is then **not** written — `requests.ts` and the hooks import types from `zod.ts` instead. To keep a separate `types.ts`, pass `withTypes: false` to the validation plugin.
112
+
113
+ **Grouping.** With `groupBy`, operation-level files (`requests`, `tanstack`, `swr`, `playwright`) are split per group, while schema-level files (`types`, `zod`, `faker`, `msw`, `mcp`, …) stay at the root:
114
+
115
+ ```
116
+ groupBy: 'tags' src/api/pets/pets.requests.ts, src/api/pets/pets.tanstack.ts
117
+ groupBy: 'endpoints' src/api/pets/get-pet/get-pet.requests.ts
118
+ groupBy: 'operations' src/api/get-pet/get-pet.requests.ts
119
+ ```
120
+
121
+ `index.ts` re-exports from every group, so `import { getPet } from './api'` works the same in every layout.
122
+
123
+ ---
124
+
125
+ ## Using the generated code
126
+
127
+ ### Request functions
128
+
129
+ For this spec operation:
130
+
131
+ ```yaml
132
+ /pets/{id}:
133
+ get:
134
+ operationId: getPet
135
+ responses:
136
+ '200': { content: { application/json: { schema: { $ref: '#/components/schemas/Pet' } } } }
137
+ '404': { content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
138
+ ```
139
+
140
+ `requests()` generates (default `fetch` client):
141
+
142
+ ```ts
143
+ export type GetPetErrors =
144
+ | { status: 404; body: Error };
145
+
146
+ export const getPet = async (id: string): Promise<Pet> => {
147
+ const r = await fetch(`/pets/${id}`);
148
+ if (!r.ok) throw new ZvyappyError(r.status, await parseErrorBody(r));
149
+ return (await r.json()) as Pet;
150
+ };
151
+ ```
152
+
153
+ Argument order is always: **path parameters** (one argument each, in path order) → **`params`** (an object of query parameters) → **`body`** → **`headers`** (an object of header parameters). Optional groups become optional arguments.
154
+
155
+ ```ts
156
+ await listPets({ limit: 20, status: 'available' }); // GET /pets?limit=20&status=available
157
+ await createPet({ name: 'Rex', status: 'available' }); // POST /pets with a JSON body
158
+ await updatePet('42', { name: 'Max' }); // PUT /pets/42
159
+ await deletePet('42'); // DELETE /pets/42 → Promise<void>
160
+ ```
161
+
162
+ - A success response with no JSON body (`204`, or `200` without content) is typed `void` and its body is never parsed.
163
+ - Query arrays and objects follow the spec's `style`/`explode` (`?id=1&id=2`, `?id=1,2`, `?id=1|2`, `?filter[a]=1`).
164
+ - `multipart/form-data` bodies become one argument per form field, sent as `FormData`.
165
+ - Paths are relative unless you set `baseUrl` — or configure the base URL on your own client instance.
166
+
167
+ ### Errors
168
+
169
+ With `errorHandling: true` (the default) a non-2xx response throws `ZvyappyError`. The class is generated into **your** output directory (`./api/config.ts`), not imported from zvyappy:
170
+
171
+ ```ts
172
+ import { getPet } from './api';
173
+ import type { GetPetErrors } from './api/requests'; // error unions are not re-exported from index.ts
174
+ import { ZvyappyError } from './api/config';
175
+
176
+ try {
177
+ await getPet('42');
178
+ } catch (e) {
179
+ if (e instanceof ZvyappyError) {
180
+ const err = e as ZvyappyError<GetPetErrors>;
181
+ console.log(err.status, err.body); // body is the parsed JSON (or text) of the error response
182
+ }
183
+ }
184
+ ```
185
+
186
+ `zvyappy/client` ships two runtime guards that work without importing the generated class — handy across package boundaries:
187
+
188
+ ```ts
189
+ import { isZvyappyError, isZvyappyStatus } from 'zvyappy/client';
190
+
191
+ if (isZvyappyStatus(e, 404)) showNotFound();
192
+ else if (isZvyappyError(e)) report(e.status, e.body);
193
+ ```
194
+
195
+ Use your own error class with `errorHandling: { path: './src/lib/errors', export: 'ApiError' }` — its constructor receives `(status, body)`. `errorHandling: false` returns whatever the client returns, with no status check.
196
+
197
+ A `default` response, or a range such as `4XX`, appears in the error union as `{ status: number; body: … }`.
198
+
199
+ ### Raw responses
200
+
201
+ `rawResponse: true` returns the status and headers alongside the body:
202
+
203
+ ```ts
204
+ const { body, status, headers } = await getPet('42'); // ZvyappyResponse<Pet>
205
+ ```
206
+
207
+ ### Using your own HTTP client
208
+
209
+ ```ts
210
+ // src/lib/http.ts
211
+ import axios from 'axios';
212
+ export const api = axios.create({ baseURL: 'https://api.example.com', withCredentials: true });
213
+ ```
214
+
215
+ ```ts
216
+ // zvyappy.config.ts
217
+ defineConfig({
218
+ httpClient: { name: 'axios', path: './src/lib/http', export: 'api' }, // path is relative to the project root
219
+ // ...
220
+ });
221
+ ```
222
+
223
+ ```ts
224
+ // generated
225
+ import { api } from '../lib/http';
226
+
227
+ export const getPet = async (id: string): Promise<Pet> => {
228
+ try {
229
+ const r = await api.get<Pet>(`/pets/${id}`);
230
+ return r.data as Pet;
231
+ } catch (e: unknown) {
232
+ // axios errors are rethrown as ZvyappyError(status, body)
233
+ }
234
+ };
235
+ ```
236
+
237
+ | `httpClient.name` | Needs | Notes |
238
+ |-------------------|-------|-------|
239
+ | `fetch` (default) | nothing | Uses global `fetch`; `path`/`export` not needed |
240
+ | `axios` | `axios` | `path` + `export` of an `AxiosInstance` |
241
+ | `ky` | `ky` | `path` + `export` of a `ky` instance |
242
+ | `ofetch` | `ofetch` | `path` + `export` of an `ofetch` instance |
243
+ | `wretch` | `wretch` | `path` + `export`; register `wretch/addons/queryString` on the instance |
244
+
245
+ Interceptors, auth headers, retries and base URLs belong on that instance — zvyappy never overrides them.
246
+
247
+ ---
248
+
249
+ ## Configuration
250
+
251
+ `zvyappy.config.ts` default-exports `defineConfig(...)` with a config object, or an array of them to generate several APIs in one run. Another file can be used with `zvyappy generate -c <path>` (`.ts` or `.js`).
252
+
253
+ ```ts
254
+ import { defineConfig, typescript, requests, zod, tanstackQuery } from 'zvyappy';
255
+
256
+ export default defineConfig({
257
+ name: 'petstore',
258
+ input: 'https://api.example.com/openapi.json',
259
+ auth: { username: process.env.SWAGGER_USER, password: process.env.SWAGGER_PASSWORD },
260
+ output: { path: './src/api', clean: true },
261
+ httpClient: { name: 'axios', path: './src/lib/http', export: 'api' },
262
+ groupBy: 'tags',
263
+ fileNaming: 'kebab-case',
264
+ enumStyle: 'const',
265
+ typeStyle: 'type',
266
+ filter: { tags: ['pets', 'store'], deprecated: false },
267
+ rename: { getPetById: 'fetchPet' },
268
+ formatter: 'prettier',
269
+ cache: { ttl: '12h' },
270
+ plugins: [typescript(), requests(), zod({ withTypes: false }), tanstackQuery()],
271
+ });
272
+ ```
273
+
274
+ ```ts
275
+ // several specs in one run
276
+ export default defineConfig([
277
+ { name: 'billing', input: './billing.yaml', output: './src/api/billing', plugins: [typescript(), requests()] },
278
+ { name: 'users', input: './users.yaml', output: './src/api/users', plugins: [typescript(), requests()] },
279
+ ]);
280
+ ```
281
+
282
+ ### All options
283
+
284
+ | Option | Type | Default | Description |
285
+ |--------|------|---------|-------------|
286
+ | `input` | `string \| () => Promise<string>` | — (required) | Spec file path (JSON/YAML), URL, or a function returning a path, URL or the spec text |
287
+ | `output` | `string \| { path, clean? }` | `'.zvyappy/generated'` | Output directory. `clean` (default `true`) empties it before writing |
288
+ | `plugins` | `ZvyappyPlugin[]` | `[]` | What to generate — see [Plugins](#plugins) |
289
+ | `name` | `string` | — | Label shown in CLI output when several configs run |
290
+ | `auth` | `{ username, password }` | — | HTTP Basic Auth for a spec behind a login. Sent only to the spec's own origin |
291
+ | `httpClient` | `{ name, path?, export? }` | `{ name: 'fetch' }` | Client used by `requests()` — see [above](#using-your-own-http-client) |
292
+ | `baseUrl` | `string` | — | Prefix for every request path, e.g. `'https://api.example.com'` or `'/api/v1'` |
293
+ | `errorHandling` | `boolean \| { path, export }` | `true` | Throw `ZvyappyError` on non-2xx; a custom class; or off |
294
+ | `rawResponse` | `boolean` | `false` | Return `{ body, status, headers }` instead of the body |
295
+ | `apiLogging` | `boolean` | `false` | `console.log(name, result)` in every request function |
296
+ | `groupBy` | `'none' \| 'tags' \| 'endpoints' \| 'operations'` | `'none'` | How operation files are split into directories |
297
+ | `fileNaming` | `'kebab-case' \| 'camelCase' \| 'snake_case' \| 'PascalCase'` | `'kebab-case'` | Naming of generated files and directories |
298
+ | `functionNaming` | `'camelCase' \| 'snake_case'` | `'camelCase'` | Naming of generated functions |
299
+ | `enumStyle` | `'const' \| 'union' \| 'enum'` | `'const'` | `const X = {…} as const`, `type X = 'a' \| 'b'`, or `enum X {…}` |
300
+ | `typeStyle` | `'type' \| 'interface'` | `'type'` | `export type X = {…}` or `export interface X {…}` |
301
+ | `filter` | `{ tags?, exclude?, deprecated? }` | — | Include only these tags / drop these tags / include deprecated operations (`false` by default once a filter is set) |
302
+ | `rename` | `Record<string, string>` | — | Rename `operationId`s before generation |
303
+ | `index` | `boolean` | `true` | Write `index.ts` |
304
+ | `endpointsMap` | `boolean` | `false` | Write `endpoints.ts` |
305
+ | `formatter` | `'prettier' \| 'biome' \| 'oxfmt' \| 'none'` | `'none'` | Format output with an installed formatter (never downloaded) |
306
+ | `hooks` | `{ afterAllFilesWrite?: string }` | — | Shell command run after files are written |
307
+ | `cache` | `boolean \| { ttl?, maxEntries? }` | `false` | Cache the parsed spec — see [Cache](#cache) |
308
+ | `versioning` | `object` | — | Snapshots of each generation — see [Versioning](#versioning) |
309
+ | `comment` | `string` | — | Note attached to this run's snapshot |
310
+ | `cliLogging` | `{ level: 'minimal' \| 'normal' \| 'detailed' }` | `{ level: 'minimal' }` | CLI verbosity |
311
+
312
+ Invalid configs fail fast with a list of every problem and a link to the relevant docs.
313
+
314
+ ### Specs behind a login
315
+
316
+ For a spec protected by HTTP Basic Auth (for example `express-basic-auth`), read the credentials from the environment:
317
+
318
+ ```ts
319
+ defineConfig({
320
+ input: 'https://api.example.com/docs-json',
321
+ auth: {
322
+ username: process.env.SWAGGER_USER,
323
+ password: process.env.SWAGGER_PASSWORD,
324
+ },
325
+ });
326
+ ```
327
+
328
+ The `Authorization` header is sent only to the spec's own origin — never to another host an external `$ref` points at. A missing variable is reported when the config is validated, and a `401`/`403` fails with a message pointing at `auth`. For any other scheme (bearer tokens, cookies), pass `input` a function that fetches the spec and returns its text.
329
+
330
+ ### Cache
331
+
332
+ `cache: true` stores the parsed spec in `.zvyappy/cache/` and skips parsing on the next run if the spec has not changed (ETag for URLs, a content hash for files). Generation itself always runs.
333
+
334
+ ```ts
335
+ cache: true // entries never expire
336
+ cache: { ttl: '7d', maxEntries: 20 } // ttl units: s, m, h, d
337
+ ```
338
+
339
+ ```bash
340
+ zvyappy cache status # what is cached
341
+ zvyappy cache clear # drop everything
342
+ ```
343
+
344
+ Entries are discarded automatically when zvyappy is upgraded. Add `.zvyappy/` to `.gitignore`.
345
+
346
+ ### Versioning
347
+
348
+ Saves a snapshot of each generation so you can diff or roll back:
349
+
350
+ ```ts
351
+ versioning: {
352
+ enabled: true,
353
+ storage: '.zvyappy/versions', // default
354
+ maxSaves: 10, // oldest removed first
355
+ pinVersions: ['<snapshot-id>'], // never pruned
356
+ saveSpec: true, // keep the spec in the snapshot
357
+ aliasTemplate: 'v{apiVersion}-gen{generation}', // vars: {generation} {apiVersion} {date}
358
+ },
359
+ ```
360
+
361
+ ```bash
362
+ zvyappy versions # list snapshots
363
+ zvyappy version show <id|alias> # details
364
+ zvyappy version checkout <id|alias> # regenerate from a snapshot
365
+ ```
366
+
367
+ ---
368
+
369
+ ## Plugins
370
+
371
+ Import every plugin from `zvyappy`. Each is a function returning a plugin object; pass options where listed.
372
+
373
+ | Plugin | Generates | Install | Requires |
374
+ |--------|-----------|---------|----------|
375
+ | `typescript()` | Types | — | — |
376
+ | `requests()` | Request functions | your HTTP client (none for fetch) | — |
377
+ | `zod(opts?)` | Zod schemas | `zod` | — |
378
+ | `valibot(opts?)` | Valibot schemas | `valibot` | — |
379
+ | `yup(opts?)` | Yup schemas | `yup` | — |
380
+ | `tanstackQuery(opts?)` | TanStack Query v5 hooks | `@tanstack/<framework>-query` | `requests()` |
381
+ | `swr(opts?)` | SWR hooks | `swr` (React) / `swrv` (Vue) | `requests()` |
382
+ | `rhf(opts)` | React Hook Form resolvers | `react-hook-form`, `@hookform/resolvers` | a validation plugin |
383
+ | `faker(opts?)` | Mock data factories | `@faker-js/faker` | — |
384
+ | `msw()` | Mock Service Worker handlers | `msw` | `faker()` |
385
+ | `playwright(opts?)` | Playwright API client + fixture | `@playwright/test` ≥ 1.30 | — |
386
+ | `mcp(opts?)` | MCP server | `@modelcontextprotocol/sdk`, `zod` | `requests()`, `zod()` |
387
+
388
+ `typescript()`, `requests()` and `msw()` take no options — client, enum and type styles are top-level config options.
389
+
390
+ ### `typescript()`
391
+
392
+ ```ts
393
+ // enumStyle: 'const' (default)
394
+ export const PetStatus = { Available: 'available', Pending: 'pending', Sold: 'sold' } as const;
395
+ export type PetStatus = typeof PetStatus[keyof typeof PetStatus];
396
+
397
+ export type Pet = {
398
+ id: string;
399
+ name: string;
400
+ status: PetStatus;
401
+ 'created-at'?: string; // names that are not identifiers are quoted
402
+ };
403
+ ```
404
+
405
+ An inline enum is named `<Schema><Property>` (`PetStatus`); if the spec already declares a schema with that name, it becomes `PetStatusEnum`.
406
+
407
+ ### `requests()`
408
+
409
+ Request functions — see [Using the generated code](#using-the-generated-code). Behaviour is set with the top-level `httpClient`, `baseUrl`, `errorHandling`, `rawResponse` and `apiLogging` options.
410
+
411
+ ### `zod()`
412
+
413
+ ```ts
414
+ zod({
415
+ withTypes: true, // emit types here; set false to keep types.ts
416
+ infer: true, // export type Pet = z.infer<typeof PetSchema>
417
+ input: false, // export type PetInput = z.input<typeof PetSchema>
418
+ output: false, // export type PetOutput = z.output<typeof PetSchema>
419
+ validateResponse: false, // export validatePetResponse(data: unknown): Pet
420
+ schemaSuffix: 'Schema',
421
+ });
422
+ ```
423
+
424
+ ```ts
425
+ export const PetSchema = z.object({
426
+ id: z.string().uuid(),
427
+ name: z.string().min(1).max(100),
428
+ status: z.enum(['available', 'pending', 'sold']),
429
+ age: z.number().min(0).optional(),
430
+ createdAt: z.string().datetime(),
431
+ });
432
+ export type Pet = z.infer<typeof PetSchema>;
433
+ ```
434
+
435
+ Maps formats (`uuid`, `email`, `uri`, `date-time`, …), `minLength`/`maxLength`, `minimum`/`maximum`, `minItems`/`maxItems`, `nullable`, `allOf` (`.and()`), `oneOf`/`anyOf` (discriminated when the spec has a `discriminator`). Recursive schemas use `z.lazy` with an explicit `z.ZodType<T>` annotation. `validateResponse` adds standalone helpers — request functions do not call them for you.
436
+
437
+ ### `valibot()` and `yup()`
438
+
439
+ ```ts
440
+ valibot({ withTypes: true, schemaSuffix: 'Schema' });
441
+ yup({ withTypes: true, schemaSuffix: 'Schema' });
442
+ ```
443
+
444
+ Same coverage as `zod()`. Valibot uses `v.pipe` for constraints, `v.picklist` for enums, `v.intersect` for `allOf`, `v.variant` for discriminated `oneOf`; types via `v.InferOutput`. Yup uses `yup.mixed<…>().oneOf()` for enums; types via `yup.InferType`. Only one validation plugin may emit types — set `withTypes: false` on the others.
445
+
446
+ ### `tanstackQuery()`
447
+
448
+ ```ts
449
+ tanstackQuery({
450
+ framework: 'react', // 'react' | 'vue' | 'svelte' | 'solid'
451
+ query: true, // query hooks for GET/QUERY operations
452
+ mutation: true, // mutation hooks for the rest
453
+ infinite: false, // useInfinity<Op>Query
454
+ suspense: false, // useSuspense<Op>Query
455
+ queryKeysStyle: 'functions', // 'functions' | 'object' (shared query-keys.ts)
456
+ hookGenerationStrategies: {
457
+ searchPets: { query: true, mutation: false }, // a POST used as a search
458
+ },
459
+ });
460
+ ```
461
+
462
+ For `operationId: listPets` / `createPet`:
463
+
464
+ ```ts
465
+ export const listPetsQueryKey = (params?: ListPetsParams) => ['listPets', ...[params]] as const;
466
+ export const listPetsQueryOptions = (params?) => queryOptions<PetList, ZvyappyError>({ queryKey: listPetsQueryKey(params), queryFn: () => listPets(params) });
467
+ export const useListPetsQuery = (params?, options?) => useQuery({ ...listPetsQueryOptions(params), ...options });
468
+ export const useCreatePetMutation = (options?) => useMutation<Pet, ZvyappyError, { body: CreatePetInput }>({ mutationFn: (vars) => createPet(vars.body), ...options });
469
+ ```
470
+
471
+ - Mutation variables are an object: `mutate({ id, body })` — path parameters by name, plus `params`, `body`, `headers` as needed.
472
+ - The error type is `ZvyappyError<GetPetErrors>` when the operation declares error responses.
473
+ - Svelte and Solid use the `create` prefix: `createListPetsQuery`, `createCreatePetMutation`.
474
+ - Infinite hooks are generated with a placeholder `getNextPageParam: () => undefined` — pass your own in `options`.
475
+
476
+ ```ts
477
+ // invalidate after a mutation
478
+ const qc = useQueryClient();
479
+ useCreatePetMutation({ onSuccess: () => qc.invalidateQueries({ queryKey: listPetsQueryKey() }) });
480
+ ```
481
+
482
+ ### `swr()`
483
+
484
+ ```ts
485
+ swr({
486
+ framework: 'react', // 'react' (swr) | 'vue' (swrv)
487
+ queryKeysStyle: 'functions', // 'functions' | 'object'
488
+ hookGenerationStrategies: {},
489
+ });
490
+ ```
491
+
492
+ ```ts
493
+ export const listPetsSwrKey = (params?) => ['listPets', ...[params]] as const;
494
+ export const useListPets = (params?, options?) => useSWR<PetList, ZvyappyError>(listPetsSwrKey(params), () => listPets(params), options);
495
+ export const useCreatePetMutation = (options?) => useSWRMutation('createPet', (_key, { arg }) => createPet(arg), options);
496
+ ```
497
+
498
+ Query hooks keep the bare name (`useListPets`); mutation hooks get a `Mutation` suffix. Cannot be combined with `tanstackQuery()` unless `index: false` — both name mutation hooks the same way.
499
+
500
+ ### `rhf()`
501
+
502
+ ```ts
503
+ rhf({
504
+ resolver: 'zod', // required: 'zod' | 'valibot' | 'yup' — that plugin must be enabled
505
+ schemaSuffix: 'Schema', // must match the validation plugin
506
+ schemasImportPath: './zod', // default './<resolver>'
507
+ });
508
+ ```
509
+
510
+ One resolver per schema:
511
+
512
+ ```ts
513
+ export const createPetInputResolver = zodResolver(CreatePetInputSchema);
514
+
515
+ // usage
516
+ const form = useForm<CreatePetInput>({ resolver: createPetInputResolver });
517
+ ```
518
+
519
+ ### `faker()`
520
+
521
+ ```ts
522
+ faker({ locale: 'en' }); // 'en' | 'ru'
523
+ ```
524
+
525
+ ```ts
526
+ export const generatePet = (): Pet => ({
527
+ id: faker.string.uuid(),
528
+ name: faker.person.fullName(),
529
+ status: faker.helpers.arrayElement(['available', 'pending', 'sold']),
530
+ createdAt: faker.date.past().toISOString(),
531
+ });
532
+
533
+ const pet = generatePet();
534
+ const pets = faker.helpers.multiple(generatePet, { count: 10 });
535
+ ```
536
+
537
+ The declared `format` wins first (`uuid`, `email`, `uri`, `date-time`, `date`, `ipv4`, …), then field-name hints for strings and numbers (`username`, `email`, `password`, `phone`, `url`/`photo`, `firstName`, `lastName`, `name`, `date`, `status`, `id`), then a value of the declared type. Recursive schemas stop after two levels (arrays become `[]`, optional fields are left out).
538
+
539
+ ### `msw()`
540
+
541
+ ```ts
542
+ export const handlers = [
543
+ http.get('/pets', () => HttpResponse.json(generatePetList())),
544
+ http.post('/pets', async ({ request }) => { await request.json(); return HttpResponse.json(generatePet()); }),
545
+ http.delete('/pets/:id', () => new HttpResponse(null, { status: 204 })),
546
+ ];
547
+ ```
548
+
549
+ ```ts
550
+ // browser
551
+ import { setupWorker } from 'msw/browser';
552
+ import { handlers } from './api';
553
+ await setupWorker(...handlers).start();
554
+
555
+ // node / tests
556
+ import { setupServer } from 'msw/node';
557
+ const server = setupServer(...handlers);
558
+ ```
559
+
560
+ ### `playwright()`
561
+
562
+ Generates a typed API **client and fixture** for Playwright — not test bodies.
563
+
564
+ ```ts
565
+ playwright({
566
+ testName: 'zvyappyPlaywrightTest', // exported test
567
+ fixtureName: 'api', // what a test destructures
568
+ baseUrl: undefined, // default: baseURL from playwright.config.ts
569
+ withFaker: false, // re-export faker factories as sample<Operation>() (needs faker())
570
+ authFixture: { // optional logged-in fixture
571
+ login: 'loginUser', // operationId of the login endpoint
572
+ strategy: 'cookie', // 'cookie' | 'bearer'
573
+ payload: '{ email: process.env.E2E_USER, password: process.env.E2E_PASS }', // or { import, from }
574
+ tokenPath: 'token', // bearer: property of the login response
575
+ header: 'Authorization', // bearer: header to send
576
+ fixtureName: 'authedApi',
577
+ },
578
+ });
579
+ ```
580
+
581
+ ```ts
582
+ import { expect } from '@playwright/test';
583
+ import { zvyappyPlaywrightTest as test } from './api/playwright';
584
+
585
+ test('creates a pet', async ({ api }) => {
586
+ const pet = await api.createPet({ name: 'Rex', status: 'available' });
587
+ expect((await api.getPet(pet.id)).name).toBe('Rex');
588
+ });
589
+ ```
590
+
591
+ `createApiClient(ctx)` takes any `APIRequestContext` — the `request` fixture, or `page.request` to share the browser's cookies. With `rawResponse: true` methods return Playwright's `APIResponse`. Under `groupBy`, exports are prefixed per group (`createPetsApiClient`, `petsZvyappyPlaywrightTest`).
592
+
593
+ ### `mcp()`
594
+
595
+ Generates a runnable [Model Context Protocol](https://modelcontextprotocol.io) server that exposes each operation as a tool, so an AI assistant can call your API. Inputs are validated with the generated Zod schemas.
596
+
597
+ ```ts
598
+ mcp({ name: 'petstore', version: '1.0.0' });
599
+ ```
600
+
601
+ ```json
602
+ // .mcp.json
603
+ { "mcpServers": { "petstore": { "command": "npx", "args": ["tsx", "src/api/mcp.ts"] } } }
604
+ ```
605
+
606
+ Multipart operations are skipped. `apiLogging` is not allowed with `mcp()` — stdout carries the protocol.
607
+
608
+ ---
609
+
610
+ ## CLI
611
+
612
+ The package installs two equivalent binaries: `zvyappy` and the short alias `zvy` (`zvy generate`, `zvy g`, …).
613
+
614
+ | Command | Alias | Description |
615
+ |---------|-------|-------------|
616
+ | `zvyappy generate` | `g` | Generate code. `-c, --config <path>` (default `zvyappy.config.ts`), `-d, --dry-run`, `-w, --watch` |
617
+ | `zvyappy start` | `s` | Interactive setup wizard — writes `zvyappy.config.ts` |
618
+ | `zvyappy config` | `c` | Scaffold `zvyappy.config.ts`. `-p, --preset <name>`, `--list-presets` |
619
+ | `zvyappy migrate <orval\|kubb\|hey-api>` | `m` | Convert another generator's config. `-t, --target <path>`, `-c, --clean` |
620
+ | `zvyappy info` | `i` | Spec statistics without generating. `-c, --config <path>` |
621
+ | `zvyappy versions` | | List snapshots. `-c, --config`, `-s, --storage <path>` |
622
+ | `zvyappy version show <id>` | | Snapshot details |
623
+ | `zvyappy version checkout <id>` | | Regenerate from a snapshot. `--dry-run` |
624
+ | `zvyappy cache status` | | Show the cache |
625
+ | `zvyappy cache clear` | | Empty the cache |
626
+
627
+ Presets for `zvyappy config --preset`: `minimal` (types + requests), `react` (+ TanStack Query + Zod), `react-swr` (+ SWR + Zod), `testing` (react + Faker + MSW), `forms` (+ Zod + React Hook Form), `full` (everything).
628
+
629
+ ---
630
+
631
+ ## Migrating from orval, kubb or Hey API
632
+
633
+ ```bash
634
+ npx zvyappy migrate orval # reads orval.config.{ts,js,mjs,...}
635
+ npx zvyappy migrate kubb # reads kubb.config.*
636
+ npx zvyappy migrate hey-api # reads openapi-ts.config.*
637
+ npx zvyappy migrate orval --target ./config/orval.config.ts --clean
638
+ ```
639
+
640
+ Writes `zvyappy.config.ts` from the existing config — input, output, plugins, grouping, tag filters, formatter, enum style and HTTP client. Anything without a zvyappy equivalent (a mutator, an SDK class, an unknown plugin, an API-registry input, auth sent as a raw header) becomes a `// TODO(migrate): …` comment in the new config and is listed in the terminal; nothing is dropped silently. Several projects writing to one directory are moved into subdirectories. It refuses to overwrite an existing `zvyappy.config.ts`.
641
+
642
+ ---
643
+
644
+ ## Renamed from `@travjek/apig`
645
+
646
+ Since 0.14.0 the package is `zvyappy` (it was `@travjek/apig` up to 0.13.0). The generator itself is unchanged — only names changed, and there is no fallback to the old ones:
647
+
648
+ | Before (≤ 0.13.0) | Since 0.14.0 |
649
+ |---|---|
650
+ | `npm install -D @travjek/apig` | `npm install -D zvyappy` |
651
+ | `apig generate` (and every other command) | `zvyappy generate`, or the short alias `zvy generate` |
652
+ | `apig.config.ts` | `zvyappy.config.ts` |
653
+ | `import { defineConfig } from '@travjek/apig'` | `import { defineConfig } from 'zvyappy'` |
654
+ | `ApigConfig`, `ApigPlugin` types | `ZvyappyConfig`, `ZvyappyPlugin` |
655
+ | `import { isApigError, isApigStatus } from '@travjek/apig/client'` | `import { isZvyappyError, isZvyappyStatus } from 'zvyappy/client'` |
656
+ | generated `ApigError`, `ApigResponse` | generated `ZvyappyError`, `ZvyappyResponse` |
657
+ | generated `apigPlaywrightTest` fixture | `zvyappyPlaywrightTest` |
658
+ | `.apig/` (cache, version snapshots, default output `.apig/generated`) | `.zvyappy/` |
659
+
660
+ To migrate:
661
+
662
+ ```bash
663
+ npm uninstall @travjek/apig && npm install -D zvyappy
664
+ mv apig.config.ts zvyappy.config.ts # then change the import to 'zvyappy'
665
+ rm -rf .apig # old cache; move .apig/versions to .zvyappy/versions to keep snapshots
666
+ npx zvyappy generate
667
+ ```
668
+
669
+ Then rename `ApigError` / `isApigError` / `isApigStatus` / `apigPlaywrightTest` in your own code. Files generated by `@travjek/apig` are still recognised and removed by `output.clean`.
670
+
671
+ ---
672
+
673
+ ## Supported OpenAPI features
674
+
675
+ - **Versions:** OpenAPI 3.0 and 3.1; Swagger 2.0 is upgraded automatically; the OpenAPI 3.2 `QUERY` method (treated as a read — query hooks, cacheable).
676
+ - **Sources:** JSON or YAML; local file, URL, or a function. External `$ref`s to neighbouring files or URLs are resolved.
677
+ - **Schemas:** objects, arrays, tuples (`prefixItems`), enums, `nullable` / `type: [..., 'null']`, `allOf`, `oneOf`/`anyOf` with or without `discriminator`, `additionalProperties`, recursive and mutually recursive schemas.
678
+ - **Constraints:** string formats, `minLength`/`maxLength`, `minimum`/`maximum`, `minItems`/`maxItems`.
679
+ - **Parameters:** path, query (with `style`/`explode`), header; `content`-style parameters.
680
+ - **Bodies:** `application/json`, `multipart/form-data`, binary uploads.
681
+ - **Responses:** `200`/`201` success types, typed error unions from `4xx`/`5xx`, `default` and range keys (`4XX`), bodiless responses (`204`).
682
+ - **Names:** any spec name is made safe — `created-at` keys are quoted, `v1.Pet` becomes `V1Pet`, reserved words and colliding `operationId`s are renamed.
683
+
684
+ ---
685
+
686
+ ## Rules and plugin compatibility
687
+
688
+ Checked when the config loads:
689
+
690
+ - `msw()` needs `faker()`; `mcp()` needs `requests()` and `zod()`; `rhf()` needs `zod()`, `valibot()` or `yup()`.
691
+ - Only one of `zod()` / `valibot()` / `yup()` may emit types — set `withTypes: false` on the others.
692
+ - `tanstackQuery()` and `swr()` together require `index: false`.
693
+ - `apiLogging` cannot be used with `mcp()`.
694
+ - A plugin may be listed only once.
695
+
696
+ ---
697
+
698
+ ## Writing a custom plugin
699
+
700
+ A plugin is an object implementing `ZvyappyPlugin`. It receives the parsed spec (IR) and returns code plus the names to re-export from `index.ts`:
701
+
702
+ ```ts
703
+ import { defineConfig, typescript, type ZvyappyPlugin } from 'zvyappy';
704
+
705
+ const routesList = (): ZvyappyPlugin => ({
706
+ name: 'routes-list',
707
+ fileName: 'routes', // → routes.ts
708
+ scope: 'root', // 'root' once for the whole spec; 'operations' once per group
709
+ generate: (ir) => ({
710
+ code: `export const ROUTES = ${JSON.stringify(ir.operations.map((op) => `${op.method} ${op.path}`))} as const;\n`,
711
+ exports: ['ROUTES'],
712
+ typeExports: [],
713
+ }),
714
+ });
715
+
716
+ export default defineConfig({ input: './openapi.json', plugins: [typescript(), routesList()] });
717
+ ```
718
+
719
+ ---
720
+
721
+ ## For AI assistants
722
+
723
+ - [`llms.txt`](./llms.txt) — a complete, plain-text reference of the config, plugins, generated names and CLI.
724
+ - A Claude Code plugin with a zvyappy skill ships in the package (`skills/zvyappy`).
725
+
726
+ ## Documentation
727
+
728
+ Full reference for every plugin, CLI command and config option: **https://apig-docs.vercel.app**
729
+
730
+ The `docs/` directory in this repository is a mirror synced from that site.
731
+
732
+ ## License
733
+
734
+ MIT