@hey-api/openapi-ts 0.89.2 → 0.90.1

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 (41) hide show
  1. package/README.md +14 -13
  2. package/dist/clients/angular/client.ts +4 -0
  3. package/dist/clients/axios/client.ts +4 -0
  4. package/dist/clients/fetch/client.ts +4 -0
  5. package/dist/clients/ky/client.ts +4 -0
  6. package/dist/clients/next/client.ts +4 -0
  7. package/dist/clients/nuxt/client.ts +5 -0
  8. package/dist/clients/nuxt/types.ts +15 -9
  9. package/dist/{config-Baq-Kb-6.d.mts → config-D5jw0Xaw.d.mts} +6582 -5475
  10. package/dist/{config-CREHWzRd.d.cts → config-Dl9mEw3s.d.cts} +4112 -3006
  11. package/dist/index.cjs +2 -1
  12. package/dist/index.d.cts +49 -32
  13. package/dist/index.d.mts +22 -5
  14. package/dist/index.mjs +2 -1
  15. package/dist/internal.cjs +2 -1
  16. package/dist/internal.d.cts +2 -1
  17. package/dist/internal.d.mts +2 -1
  18. package/dist/internal.mjs +2 -1
  19. package/dist/openApi-BfsCCQJN.mjs +14 -0
  20. package/dist/openApi-BfsCCQJN.mjs.map +1 -0
  21. package/dist/openApi-VRTfi3V4.cjs +14 -0
  22. package/dist/openApi-VRTfi3V4.cjs.map +1 -0
  23. package/dist/run.cjs +3 -1
  24. package/dist/run.cjs.map +1 -1
  25. package/dist/run.d.cts +1 -0
  26. package/dist/run.d.mts +1 -0
  27. package/dist/run.mjs +3 -1
  28. package/dist/run.mjs.map +1 -1
  29. package/dist/src-CB7dCcql.cjs +20 -0
  30. package/dist/src-CB7dCcql.cjs.map +1 -0
  31. package/dist/src-DxXY6pL5.mjs +12 -0
  32. package/dist/src-DxXY6pL5.mjs.map +1 -0
  33. package/package.json +6 -6
  34. package/dist/openApi-DV_SToAE.cjs +0 -13
  35. package/dist/openApi-DV_SToAE.cjs.map +0 -1
  36. package/dist/openApi-Dz9FsU_q.mjs +0 -13
  37. package/dist/openApi-Dz9FsU_q.mjs.map +0 -1
  38. package/dist/src-CnDKH9rV.cjs +0 -19
  39. package/dist/src-CnDKH9rV.cjs.map +0 -1
  40. package/dist/src-novPNOHw.mjs +0 -11
  41. package/dist/src-novPNOHw.mjs.map +0 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
  <p align="center">
15
15
  <a href="https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fsdk.gen.ts,src%2Fclient%2Ftypes.gen.ts">Demo</a>
16
16
  <span>&nbsp;•&nbsp;</span>
17
- <a href="https://heyapi.dev">Docs</a>
17
+ <a href="https://heyapi.dev">Manual</a>
18
18
  <span>&nbsp;•&nbsp;</span>
19
19
  <a href="https://github.com/hey-api/openapi-ts/issues">Issues</a>
20
20
  <span>&nbsp;•&nbsp;</span>
@@ -23,21 +23,22 @@
23
23
 
24
24
  ## About
25
25
 
26
- [@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts) is an [open source](https://github.com/hey-api/openapi-ts/blob/main/LICENSE.md) OpenAPI to TypeScript code generator trusted by companies like Google, Amazon, and PayPal to generate API clients, SDKs, validators, and more. We also build complementary tools and [services](https://app.heyapi.dev/) that help teams design, manage, and distribute APIs more effectively.
26
+ The OpenAPI to TypeScript code generator used by Vercel, OpenCode, and PayPal.
27
27
 
28
- ## Features
28
+ Generate production-ready SDKs, Zod schemas, TanStack Query hooks, or choose from 20+ other plugins.
29
29
 
30
- - runs in CLI, Node.js 20+, or npx
31
- - works with OpenAPI 2.0, 3.0, and 3.1
32
- - core plugins for types, SDKs, and schemas
33
- - clients for your runtime (Fetch API, Angular, Axios, Next.js, Nuxt, etc.)
34
- - plugin ecosystem to reduce third-party boilerplate
35
- - custom plugins and custom clients
36
- - [integration](https://heyapi.dev/openapi-ts/integrations) with Hey API Platform
30
+ Part of the Hey API ecosystem.
37
31
 
38
- ## Dashboard
32
+ ## Features
39
33
 
40
- Access your projects and OpenAPI specifications in the [Hey API Platform](https://app.heyapi.dev/).
34
+ - production-ready code that compiles
35
+ - runs in any Node.js 20+ environment
36
+ - accepts any OpenAPI specification
37
+ - core plugins for SDKs, types, and schemas
38
+ - HTTP clients for Fetch API, Angular, Axios, Next.js, Nuxt, and more
39
+ - 20+ plugins to reduce third-party boilerplate
40
+ - highly customizable via plugins
41
+ - [sync with Hey API Registry](https://heyapi.dev/openapi-ts/integrations) for spec management
41
42
 
42
43
  ## Contributing
43
44
 
@@ -47,7 +48,7 @@ Start with our [Contributing](https://heyapi.dev/openapi-ts/community/contributi
47
48
 
48
49
  ## Sponsors
49
50
 
50
- Help Hey API stay around for the long haul by becoming a [sponsor](https://github.com/sponsors/hey-api).
51
+ Hey API is sponsor-funded. If you rely on Hey API in production, consider becoming a [sponsor](https://github.com/sponsors/hey-api) to accelerate the roadmap.
51
52
 
52
53
  <h3 align="center">Gold</h3>
53
54
 
@@ -212,6 +212,10 @@ export const createClient = (config: Config = {}): Client => {
212
212
  body: opts.body as BodyInit | null | undefined,
213
213
  headers: opts.headers as unknown as Record<string, string>,
214
214
  method,
215
+ serializedBody: getValidRequestBody(opts) as
216
+ | BodyInit
217
+ | null
218
+ | undefined,
215
219
  url,
216
220
  });
217
221
  };
@@ -125,6 +125,10 @@ export const createClient = (config: Config = {}): Client => {
125
125
  body: opts.body as BodyInit | null | undefined,
126
126
  headers: opts.headers as Record<string, string>,
127
127
  method,
128
+ serializedBody: getValidRequestBody(opts) as
129
+ | BodyInit
130
+ | null
131
+ | undefined,
128
132
  // @ts-expect-error
129
133
  signal: opts.signal,
130
134
  url,
@@ -265,6 +265,10 @@ export const createClient = (config: Config = {}): Client => {
265
265
  }
266
266
  return request;
267
267
  },
268
+ serializedBody: getValidRequestBody(opts) as
269
+ | BodyInit
270
+ | null
271
+ | undefined,
268
272
  url,
269
273
  });
270
274
  };
@@ -305,6 +305,10 @@ export const createClient = (config: Config = {}): Client => {
305
305
  }
306
306
  return request;
307
307
  },
308
+ serializedBody: getValidRequestBody(opts) as
309
+ | BodyInit
310
+ | null
311
+ | undefined,
308
312
  url,
309
313
  });
310
314
  };
@@ -226,6 +226,10 @@ export const createClient = (config: Config = {}): Client => {
226
226
  }
227
227
  return request;
228
228
  },
229
+ serializedBody: getValidRequestBody(opts) as
230
+ | BodyInit
231
+ | null
232
+ | undefined,
229
233
  url,
230
234
  });
231
235
  };
@@ -8,6 +8,7 @@ import { reactive, ref, watch } from 'vue';
8
8
 
9
9
  import { createSseClient } from '../core/serverSentEvents';
10
10
  import type { HttpMethod } from '../core/types';
11
+ import { getValidRequestBody } from '../core/utils';
11
12
  import type { Client, Config, RequestOptions } from './types';
12
13
  import {
13
14
  buildUrl,
@@ -193,6 +194,10 @@ export const createClient = (config: Config = {}): Client => {
193
194
  body: opts.body as BodyInit | null | undefined,
194
195
  method,
195
196
  onRequest: undefined,
197
+ serializedBody: getValidRequestBody(opts) as
198
+ | BodyInit
199
+ | null
200
+ | undefined,
196
201
  signal: unwrapRefs(opts.signal) as AbortSignal,
197
202
  url,
198
203
  });
@@ -31,8 +31,14 @@ export type QuerySerializer = (
31
31
 
32
32
  type WithRefs<TData> = {
33
33
  [K in keyof TData]: NonNullable<TData[K]> extends object
34
- ? WithRefs<NonNullable<TData[K]>> | Ref<NonNullable<TData[K]>>
35
- : NonNullable<TData[K]> | Ref<NonNullable<TData[K]>>;
34
+ ?
35
+ | WithRefs<NonNullable<TData[K]>>
36
+ | Ref<NonNullable<TData[K]>>
37
+ | Extract<TData[K], null>
38
+ :
39
+ | NonNullable<TData[K]>
40
+ | Ref<NonNullable<TData[K]>>
41
+ | Extract<TData[K], null>;
36
42
  };
37
43
 
38
44
  // copied from Nuxt
@@ -68,15 +74,8 @@ export interface RequestOptions<
68
74
  Url extends string = string,
69
75
  > extends Config,
70
76
  WithRefs<{
71
- /**
72
- * Any body that you want to add to your request.
73
- *
74
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
75
- */
76
- body?: unknown;
77
77
  path?: FetchOptions<unknown>['query'];
78
78
  query?: FetchOptions<unknown>['query'];
79
- rawBody?: unknown;
80
79
  }>,
81
80
  Pick<
82
81
  ServerSentEventsOptions<ResT>,
@@ -87,8 +86,15 @@ export interface RequestOptions<
87
86
  | 'sseMaxRetryDelay'
88
87
  > {
89
88
  asyncDataOptions?: AsyncDataOptions<ResT, ResT, KeysOf<ResT>, DefaultT>;
89
+ /**
90
+ * Any body that you want to add to your request.
91
+ *
92
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
93
+ */
94
+ body?: NonNullable<unknown> | Ref<NonNullable<unknown>> | null;
90
95
  composable?: TComposable;
91
96
  key?: string;
97
+ rawBody?: NonNullable<unknown> | Ref<NonNullable<unknown>> | null;
92
98
  /**
93
99
  * Security mechanism(s) to use for the request.
94
100
  */