@hey-api/openapi-ts 0.97.0 → 0.97.2
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.
- package/README.md +16 -8
- package/dist/clients/angular/client.ts +1 -4
- package/dist/clients/angular/utils.ts +7 -8
- package/dist/clients/axios/client.ts +1 -4
- package/dist/clients/axios/utils.ts +6 -8
- package/dist/clients/fetch/client.ts +1 -4
- package/dist/clients/fetch/utils.ts +6 -8
- package/dist/clients/ky/client.ts +1 -4
- package/dist/clients/ky/utils.ts +6 -8
- package/dist/clients/next/client.ts +1 -4
- package/dist/clients/next/utils.ts +6 -8
- package/dist/clients/nuxt/client.ts +7 -6
- package/dist/clients/nuxt/utils.ts +6 -8
- package/dist/clients/ofetch/client.ts +1 -4
- package/dist/clients/ofetch/utils.ts +6 -8
- package/dist/index.d.mts +419 -208
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{init-EigcXVTH.mjs → init-CitwzRmB.mjs} +751 -356
- package/dist/init-CitwzRmB.mjs.map +1 -0
- package/dist/internal.mjs +1 -1
- package/dist/run.mjs +2 -2
- package/dist/{src-ErSC87Z1.mjs → src-DEol_iHK.mjs} +2 -2
- package/dist/{src-ErSC87Z1.mjs.map → src-DEol_iHK.mjs.map} +1 -1
- package/package.json +4 -4
- package/dist/init-EigcXVTH.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -19,20 +19,20 @@
|
|
|
19
19
|
<span> • </span>
|
|
20
20
|
<a href="https://github.com/hey-api/openapi-ts/issues">Issues</a>
|
|
21
21
|
<span> • </span>
|
|
22
|
-
<a href="https://heyapi.dev/openapi
|
|
22
|
+
<a href="https://heyapi.dev/docs/openapi/typescript/community/contributing">Contribute</a>
|
|
23
23
|
</p>
|
|
24
24
|
|
|
25
25
|
## About
|
|
26
26
|
|
|
27
27
|
The OpenAPI to TypeScript code generator used by Vercel, OpenCode, and PayPal.
|
|
28
28
|
|
|
29
|
-
Generate production-
|
|
29
|
+
Generate production-grade SDKs, Zod schemas, TanStack Query hooks, or choose from 20+ other plugins.
|
|
30
30
|
|
|
31
31
|
Part of the Hey API ecosystem.
|
|
32
32
|
|
|
33
33
|
## Features
|
|
34
34
|
|
|
35
|
-
- production-
|
|
35
|
+
- production-grade code that compiles
|
|
36
36
|
- runs in any Node.js 22+ environment
|
|
37
37
|
- accepts any OpenAPI specification
|
|
38
38
|
- core plugins for SDKs, types, and schemas
|
|
@@ -47,7 +47,7 @@ Part of the Hey API ecosystem.
|
|
|
47
47
|
|
|
48
48
|
Want to see your code in products used by millions?
|
|
49
49
|
|
|
50
|
-
Start with our [Contributing](https://heyapi.dev/openapi
|
|
50
|
+
Start with our [Contributing](https://heyapi.dev/docs/openapi/typescript/community/contributing) guide and release your first feature.
|
|
51
51
|
|
|
52
52
|
<!-- template-contributing-end -->
|
|
53
53
|
|
|
@@ -156,6 +156,14 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
|
|
|
156
156
|
</picture>
|
|
157
157
|
</a>
|
|
158
158
|
</td>
|
|
159
|
+
<td align="center" width="136px">
|
|
160
|
+
<a href="https://kutt.to/HW4GYR" target="_blank">
|
|
161
|
+
<picture height="34px">
|
|
162
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/photon/logo-light.svg">
|
|
163
|
+
<img alt="Photon logo" height="34px" src="https://heyapi.dev/assets/photon/logo-dark.svg">
|
|
164
|
+
</picture>
|
|
165
|
+
</a>
|
|
166
|
+
</td>
|
|
159
167
|
</tr>
|
|
160
168
|
</tbody>
|
|
161
169
|
</table>
|
|
@@ -178,7 +186,7 @@ You can download `@hey-api/openapi-ts` from npm using your favorite package mana
|
|
|
178
186
|
#### npm
|
|
179
187
|
|
|
180
188
|
```sh
|
|
181
|
-
npm
|
|
189
|
+
npm install @hey-api/openapi-ts -D -E
|
|
182
190
|
```
|
|
183
191
|
|
|
184
192
|
#### pnpm
|
|
@@ -196,7 +204,7 @@ yarn add @hey-api/openapi-ts -D -E
|
|
|
196
204
|
#### bun
|
|
197
205
|
|
|
198
206
|
```sh
|
|
199
|
-
bun add @hey-api/openapi-ts -D
|
|
207
|
+
bun add @hey-api/openapi-ts -D
|
|
200
208
|
```
|
|
201
209
|
|
|
202
210
|
### Versioning
|
|
@@ -241,7 +249,7 @@ If you're using [Vite](https://vite.dev), you can integrate `@hey-api/openapi-ts
|
|
|
241
249
|
#### npm
|
|
242
250
|
|
|
243
251
|
```sh
|
|
244
|
-
npm
|
|
252
|
+
npm install @hey-api/vite-plugin -D -E
|
|
245
253
|
```
|
|
246
254
|
|
|
247
255
|
#### pnpm
|
|
@@ -259,7 +267,7 @@ yarn add @hey-api/vite-plugin -D -E
|
|
|
259
267
|
#### bun
|
|
260
268
|
|
|
261
269
|
```sh
|
|
262
|
-
bun add @hey-api/vite-plugin -D
|
|
270
|
+
bun add @hey-api/vite-plugin -D
|
|
263
271
|
```
|
|
264
272
|
|
|
265
273
|
Then add the plugin to your Vite configuration:
|
|
@@ -106,10 +106,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
106
106
|
const { opts, req, url } = requestOptions(options);
|
|
107
107
|
|
|
108
108
|
if (opts.security) {
|
|
109
|
-
await setAuthParams(
|
|
110
|
-
...opts,
|
|
111
|
-
security: opts.security,
|
|
112
|
-
});
|
|
109
|
+
await setAuthParams(opts);
|
|
113
110
|
}
|
|
114
111
|
|
|
115
112
|
if (opts.requestValidator) {
|
|
@@ -180,13 +180,12 @@ export const getParseAs = (
|
|
|
180
180
|
return;
|
|
181
181
|
};
|
|
182
182
|
|
|
183
|
-
export
|
|
184
|
-
options: Pick<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
)
|
|
189
|
-
for (const auth of options.security) {
|
|
183
|
+
export async function setAuthParams(
|
|
184
|
+
options: Pick<RequestOptions, 'auth' | 'query' | 'security'> & {
|
|
185
|
+
headers: HttpHeaders;
|
|
186
|
+
},
|
|
187
|
+
): Promise<void> {
|
|
188
|
+
for (const auth of options.security ?? []) {
|
|
190
189
|
const token = await getAuthToken(auth, options.auth);
|
|
191
190
|
|
|
192
191
|
if (!token) {
|
|
@@ -213,7 +212,7 @@ export const setAuthParams = async (
|
|
|
213
212
|
|
|
214
213
|
return;
|
|
215
214
|
}
|
|
216
|
-
}
|
|
215
|
+
}
|
|
217
216
|
|
|
218
217
|
export const buildUrl: Client['buildUrl'] = (options) => {
|
|
219
218
|
const url = getUrl({
|
|
@@ -81,14 +81,12 @@ const checkForExistence = (
|
|
|
81
81
|
return false;
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
export
|
|
85
|
-
security
|
|
86
|
-
...options
|
|
87
|
-
}: Pick<Required<RequestOptions>, 'security'> &
|
|
88
|
-
Pick<RequestOptions, 'auth' | 'query'> & {
|
|
84
|
+
export async function setAuthParams(
|
|
85
|
+
options: Pick<RequestOptions, 'auth' | 'query' | 'security'> & {
|
|
89
86
|
headers: Record<any, unknown>;
|
|
90
|
-
}
|
|
91
|
-
|
|
87
|
+
},
|
|
88
|
+
): Promise<void> {
|
|
89
|
+
for (const auth of options.security ?? []) {
|
|
92
90
|
if (checkForExistence(options, auth.name)) {
|
|
93
91
|
continue;
|
|
94
92
|
}
|
|
@@ -122,7 +120,7 @@ export const setAuthParams = async ({
|
|
|
122
120
|
break;
|
|
123
121
|
}
|
|
124
122
|
}
|
|
125
|
-
}
|
|
123
|
+
}
|
|
126
124
|
|
|
127
125
|
export const buildUrl: Client['buildUrl'] = (options) => {
|
|
128
126
|
const instanceBaseUrl = options.axios?.defaults?.baseURL;
|
|
@@ -116,14 +116,12 @@ const checkForExistence = (
|
|
|
116
116
|
return false;
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
-
export
|
|
120
|
-
security
|
|
121
|
-
...options
|
|
122
|
-
}: Pick<Required<RequestOptions>, 'security'> &
|
|
123
|
-
Pick<RequestOptions, 'auth' | 'query'> & {
|
|
119
|
+
export async function setAuthParams(
|
|
120
|
+
options: Pick<RequestOptions, 'auth' | 'query' | 'security'> & {
|
|
124
121
|
headers: Headers;
|
|
125
|
-
}
|
|
126
|
-
|
|
122
|
+
},
|
|
123
|
+
): Promise<void> {
|
|
124
|
+
for (const auth of options.security ?? []) {
|
|
127
125
|
if (checkForExistence(options, auth.name)) {
|
|
128
126
|
continue;
|
|
129
127
|
}
|
|
@@ -152,7 +150,7 @@ export const setAuthParams = async ({
|
|
|
152
150
|
break;
|
|
153
151
|
}
|
|
154
152
|
}
|
|
155
|
-
}
|
|
153
|
+
}
|
|
156
154
|
|
|
157
155
|
export const buildUrl: Client['buildUrl'] = (options) =>
|
|
158
156
|
getUrl({
|
package/dist/clients/ky/utils.ts
CHANGED
|
@@ -114,14 +114,12 @@ const checkForExistence = (
|
|
|
114
114
|
return false;
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
export
|
|
118
|
-
security
|
|
119
|
-
...options
|
|
120
|
-
}: Pick<Required<RequestOptions>, 'security'> &
|
|
121
|
-
Pick<RequestOptions, 'auth' | 'query'> & {
|
|
117
|
+
export async function setAuthParams(
|
|
118
|
+
options: Pick<RequestOptions, 'auth' | 'query' | 'security'> & {
|
|
122
119
|
headers: Headers;
|
|
123
|
-
}
|
|
124
|
-
|
|
120
|
+
},
|
|
121
|
+
): Promise<void> {
|
|
122
|
+
for (const auth of options.security ?? []) {
|
|
125
123
|
if (checkForExistence(options, auth.name)) {
|
|
126
124
|
continue;
|
|
127
125
|
}
|
|
@@ -150,7 +148,7 @@ export const setAuthParams = async ({
|
|
|
150
148
|
break;
|
|
151
149
|
}
|
|
152
150
|
}
|
|
153
|
-
}
|
|
151
|
+
}
|
|
154
152
|
|
|
155
153
|
export const buildUrl: Client['buildUrl'] = (options) =>
|
|
156
154
|
getUrl({
|
|
@@ -196,14 +196,12 @@ const checkForExistence = (
|
|
|
196
196
|
return false;
|
|
197
197
|
};
|
|
198
198
|
|
|
199
|
-
export
|
|
200
|
-
security
|
|
201
|
-
...options
|
|
202
|
-
}: Pick<Required<RequestOptions>, 'security'> &
|
|
203
|
-
Pick<RequestOptions, 'auth' | 'query'> & {
|
|
199
|
+
export async function setAuthParams(
|
|
200
|
+
options: Pick<RequestOptions, 'auth' | 'query' | 'security'> & {
|
|
204
201
|
headers: Headers;
|
|
205
|
-
}
|
|
206
|
-
|
|
202
|
+
},
|
|
203
|
+
): Promise<void> {
|
|
204
|
+
for (const auth of options.security ?? []) {
|
|
207
205
|
if (checkForExistence(options, auth.name)) {
|
|
208
206
|
continue;
|
|
209
207
|
}
|
|
@@ -231,7 +229,7 @@ export const setAuthParams = async ({
|
|
|
231
229
|
break;
|
|
232
230
|
}
|
|
233
231
|
}
|
|
234
|
-
}
|
|
232
|
+
}
|
|
235
233
|
|
|
236
234
|
export const buildUrl: Client['buildUrl'] = (options) => {
|
|
237
235
|
const url = getUrl({
|
|
@@ -38,10 +38,7 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
if (opts.security) {
|
|
41
|
-
await setAuthParams(
|
|
42
|
-
...opts,
|
|
43
|
-
security: opts.security,
|
|
44
|
-
});
|
|
41
|
+
await setAuthParams(opts);
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
if (opts.requestValidator) {
|
|
@@ -72,12 +69,16 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
72
69
|
opts.onRequest = [
|
|
73
70
|
async ({ options }) => {
|
|
74
71
|
if (security) {
|
|
75
|
-
|
|
72
|
+
const authOpts: Parameters<typeof setAuthParams>[0] = {
|
|
76
73
|
auth: opts.auth,
|
|
77
74
|
headers: options.headers,
|
|
78
75
|
query: options.query,
|
|
79
76
|
security,
|
|
80
|
-
}
|
|
77
|
+
};
|
|
78
|
+
await setAuthParams(authOpts);
|
|
79
|
+
if (authOpts.query !== options.query) {
|
|
80
|
+
options.query = authOpts.query;
|
|
81
|
+
}
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
if (requestValidator) {
|
|
@@ -163,14 +163,12 @@ const checkForExistence = (
|
|
|
163
163
|
return false;
|
|
164
164
|
};
|
|
165
165
|
|
|
166
|
-
export
|
|
167
|
-
security
|
|
168
|
-
...options
|
|
169
|
-
}: Pick<Required<RequestOptions>, 'security'> &
|
|
170
|
-
Pick<RequestOptions, 'auth' | 'query'> & {
|
|
166
|
+
export async function setAuthParams(
|
|
167
|
+
options: Pick<RequestOptions, 'auth' | 'query' | 'security'> & {
|
|
171
168
|
headers: Headers;
|
|
172
|
-
}
|
|
173
|
-
|
|
169
|
+
},
|
|
170
|
+
): Promise<void> {
|
|
171
|
+
for (const auth of options.security ?? []) {
|
|
174
172
|
if (checkForExistence(options, auth.name)) {
|
|
175
173
|
continue;
|
|
176
174
|
}
|
|
@@ -202,7 +200,7 @@ export const setAuthParams = async ({
|
|
|
202
200
|
break;
|
|
203
201
|
}
|
|
204
202
|
}
|
|
205
|
-
}
|
|
203
|
+
}
|
|
206
204
|
|
|
207
205
|
export const buildUrl: Client['buildUrl'] = (options) => {
|
|
208
206
|
const url = getUrl({
|
|
@@ -147,14 +147,12 @@ const checkForExistence = (
|
|
|
147
147
|
return false;
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
export
|
|
151
|
-
security
|
|
152
|
-
...options
|
|
153
|
-
}: Pick<Required<RequestOptions>, 'security'> &
|
|
154
|
-
Pick<RequestOptions, 'auth' | 'query'> & {
|
|
150
|
+
export async function setAuthParams(
|
|
151
|
+
options: Pick<RequestOptions, 'auth' | 'query' | 'security'> & {
|
|
155
152
|
headers: Headers;
|
|
156
|
-
}
|
|
157
|
-
|
|
153
|
+
},
|
|
154
|
+
): Promise<void> {
|
|
155
|
+
for (const auth of options.security ?? []) {
|
|
158
156
|
if (checkForExistence(options, auth.name)) {
|
|
159
157
|
continue;
|
|
160
158
|
}
|
|
@@ -183,7 +181,7 @@ export const setAuthParams = async ({
|
|
|
183
181
|
break;
|
|
184
182
|
}
|
|
185
183
|
}
|
|
186
|
-
}
|
|
184
|
+
}
|
|
187
185
|
|
|
188
186
|
export const buildUrl: Client['buildUrl'] = (options) =>
|
|
189
187
|
getUrl({
|