@hey-api/openapi-ts 0.89.1 → 0.90.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 (39) hide show
  1. package/README.md +27 -24
  2. package/dist/clients/angular/client.ts +4 -0
  3. package/dist/clients/axios/client.ts +5 -1
  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-Duuay7XM.d.cts → config-DT26kmcq.d.cts} +2493 -1614
  10. package/dist/{config-DsA-xawl.d.mts → config-Dis5Gu6e.d.mts} +2492 -1613
  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-BU6F2oHy.mjs +14 -0
  20. package/dist/openApi-BU6F2oHy.mjs.map +1 -0
  21. package/dist/openApi-CcUF29dR.cjs +14 -0
  22. package/dist/openApi-CcUF29dR.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-T7IO6Tfr.cjs → src-CHy94xdb.cjs} +5 -4
  30. package/dist/src-CHy94xdb.cjs.map +1 -0
  31. package/dist/{src-DwGvCacY.mjs → src-DnaJOx9H.mjs} +5 -4
  32. package/dist/src-DnaJOx9H.mjs.map +1 -0
  33. package/package.json +6 -6
  34. package/dist/openApi-C6rgbKAs.mjs +0 -13
  35. package/dist/openApi-C6rgbKAs.mjs.map +0 -1
  36. package/dist/openApi-DbVAMWYK.cjs +0 -13
  37. package/dist/openApi-DbVAMWYK.cjs.map +0 -1
  38. package/dist/src-DwGvCacY.mjs.map +0 -1
  39. package/dist/src-T7IO6Tfr.cjs.map +0 -1
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img alt="Hey API presents openapi-ts" height="214" src="https://heyapi.dev/images/openapi-ts-hero-640w.png" width="438">
2
+ <img alt="Hey API presents openapi-ts" height="214" src="https://heyapi.dev/assets/.gen/openapi-ts-hero-640w.png" width="438">
3
3
  <h1><b>OpenAPI TypeScript</b></h1>
4
4
  <p><em>“OpenAPI codegen that just works.”</em><br/><sub>— Guillermo Rauch, CEO of Vercel</sub></p>
5
5
  </div>
@@ -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
 
@@ -59,8 +60,8 @@ Help Hey API stay around for the long haul by becoming a [sponsor](https://githu
59
60
  <p>
60
61
  <a href="https://kutt.it/pkEZyc" target="_blank">
61
62
  <picture height="50px">
62
- <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/images/stainless-logo-wordmark-480w.jpeg">
63
- <img alt="Stainless logo" height="50px" src="https://heyapi.dev/images/stainless-logo-wordmark-480w.jpeg">
63
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/.gen/stainless-logo-wordmark-480w.jpeg">
64
+ <img alt="Stainless logo" height="50px" src="https://heyapi.dev/assets/.gen/stainless-logo-wordmark-480w.jpeg">
64
65
  </picture>
65
66
  </a>
66
67
  <br/>
@@ -77,7 +78,8 @@ Help Hey API stay around for the long haul by becoming a [sponsor](https://githu
77
78
  <p>
78
79
  <a href="https://kutt.it/QM9Q2N" target="_blank">
79
80
  <picture height="50px">
80
- <img alt="Opencode logo" height="50px" src="https://heyapi.dev/opencode-logo-wordmark.svg">
81
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/opencode/logo-light.svg">
82
+ <img alt="Opencode logo" height="50px" src="https://heyapi.dev/assets/opencode/logo-dark.svg">
81
83
  </picture>
82
84
  </a>
83
85
  <br/>
@@ -101,8 +103,8 @@ Help Hey API stay around for the long haul by becoming a [sponsor](https://githu
101
103
  <td align="center">
102
104
  <a href="https://kutt.it/skQUVd" target="_blank">
103
105
  <picture height="40px">
104
- <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/images/scalar-logo-wordmark-480w.jpeg">
105
- <img alt="Scalar logo" height="40px" src="https://heyapi.dev/scalar-logo-wordmark.svg">
106
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/scalar/logo-light.svg">
107
+ <img alt="Scalar logo" height="40px" src="https://heyapi.dev/assets/scalar/logo-dark.svg">
106
108
  </picture>
107
109
  </a>
108
110
  <br/>
@@ -113,7 +115,8 @@ Help Hey API stay around for the long haul by becoming a [sponsor](https://githu
113
115
  <td align="center">
114
116
  <a href="https://kutt.it/Dr9GuW" target="_blank">
115
117
  <picture height="40px">
116
- <img alt="FastAPI logo" height="40px" src="https://heyapi.dev/fastapi-logo-wordmark.svg">
118
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/fastapi/logo-light.svg">
119
+ <img alt="FastAPI logo" height="40px" src="https://heyapi.dev/assets/fastapi/logo-dark.svg">
117
120
  </picture>
118
121
  </a>
119
122
  <br/>
@@ -133,16 +136,16 @@ Help Hey API stay around for the long haul by becoming a [sponsor](https://githu
133
136
  <td align="center">
134
137
  <a href="https://kutt.it/YpaKsX" target="_blank">
135
138
  <picture height="34px">
136
- <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/images/kinde-logo-wordmark-dark-480w.webp">
137
- <img alt="Kinde logo" height="34px" src="https://heyapi.dev/images/kinde-logo-wordmark-480w.jpeg">
139
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/.gen/kinde-logo-wordmark-dark-480w.webp">
140
+ <img alt="Kinde logo" height="34px" src="https://heyapi.dev/assets/.gen/kinde-logo-wordmark-480w.jpeg">
138
141
  </picture>
139
142
  </a>
140
143
  </td>
141
144
  <td align="center">
142
145
  <a href="https://kutt.it/KkqSaw" target="_blank">
143
146
  <picture height="34px">
144
- <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/images/cella-logo-wordmark-480w.webp">
145
- <img alt="Cella logo" height="34px" src="https://heyapi.dev/cella-logo-wordmark.svg">
147
+ <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/cella/logo-light.svg">
148
+ <img alt="Cella logo" height="34px" src="https://heyapi.dev/assets/cella/logo-dark.svg">
146
149
  </picture>
147
150
  </a>
148
151
  </td>
@@ -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
  };
@@ -82,7 +82,7 @@ export const createClient = (config: Config = {}): Client => {
82
82
  data: getValidRequestBody(opts),
83
83
  headers: opts.headers as RawAxiosRequestHeaders,
84
84
  // let `paramsSerializer()` handle query params if it exists
85
- params: !opts.paramsSerializer ? opts.query : undefined,
85
+ params: opts.paramsSerializer ? opts.query : undefined,
86
86
  url,
87
87
  });
88
88
 
@@ -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
  */