@hey-api/openapi-ts 0.82.4 → 0.83.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.
- package/dist/chunk-XDXACE7V.js +57 -0
- package/dist/chunk-XDXACE7V.js.map +1 -0
- package/dist/clients/angular/client.ts +1 -19
- package/dist/clients/axios/client.ts +1 -17
- package/dist/clients/core/utils.ts +30 -1
- package/dist/clients/fetch/client.ts +1 -20
- package/dist/clients/fetch/utils.ts +12 -2
- package/dist/clients/next/client.ts +1 -20
- package/dist/clients/next/utils.ts +11 -1
- package/dist/clients/nuxt/utils.ts +9 -1
- package/dist/index.cjs +207 -201
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +25 -19
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/{types.d-44bOq98L.d.cts → types.d-CcDC5oij.d.cts} +413 -295
- package/dist/{types.d-44bOq98L.d.ts → types.d-CcDC5oij.d.ts} +413 -295
- package/package.json +2 -4
- package/dist/chunk-AD7MLPQS.js +0 -51
- package/dist/chunk-AD7MLPQS.js.map +0 -1
|
@@ -16,6 +16,7 @@ import { filter } from 'rxjs/operators';
|
|
|
16
16
|
|
|
17
17
|
import { createSseClient } from '../core/serverSentEvents';
|
|
18
18
|
import type { HttpMethod } from '../core/types';
|
|
19
|
+
import { getValidRequestBody } from '../core/utils';
|
|
19
20
|
import type {
|
|
20
21
|
Client,
|
|
21
22
|
Config,
|
|
@@ -199,25 +200,6 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
199
200
|
}
|
|
200
201
|
};
|
|
201
202
|
|
|
202
|
-
function getValidRequestBody(options: ResolvedRequestOptions) {
|
|
203
|
-
const hasBody = options.body !== undefined;
|
|
204
|
-
const isSerializedBody = hasBody && options.bodySerializer;
|
|
205
|
-
|
|
206
|
-
if (isSerializedBody) {
|
|
207
|
-
const hasSerializedBody =
|
|
208
|
-
options.serializedBody !== undefined && options.serializedBody !== '';
|
|
209
|
-
|
|
210
|
-
return hasSerializedBody ? options.serializedBody : null;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// plain/text body
|
|
214
|
-
if (hasBody) {
|
|
215
|
-
return options.body;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return undefined;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
203
|
const makeMethodFn =
|
|
222
204
|
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
|
|
223
205
|
request({ ...options, method });
|
|
@@ -3,6 +3,7 @@ import axios from 'axios';
|
|
|
3
3
|
|
|
4
4
|
import { createSseClient } from '../core/serverSentEvents';
|
|
5
5
|
import type { HttpMethod } from '../core/types';
|
|
6
|
+
import { getValidRequestBody } from '../core/utils';
|
|
6
7
|
import type { Client, Config, RequestOptions } from './types';
|
|
7
8
|
import {
|
|
8
9
|
buildUrl,
|
|
@@ -112,23 +113,6 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
112
113
|
}
|
|
113
114
|
};
|
|
114
115
|
|
|
115
|
-
function getValidRequestBody(options: RequestOptions) {
|
|
116
|
-
const hasBody = options.body !== undefined;
|
|
117
|
-
const isSerializedBody = hasBody && options.bodySerializer;
|
|
118
|
-
|
|
119
|
-
if (isSerializedBody) {
|
|
120
|
-
return options.body !== '' ? options.body : null;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// plain/text body
|
|
124
|
-
if (hasBody) {
|
|
125
|
-
return options.body;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// no body was provided
|
|
129
|
-
return undefined;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
116
|
const makeMethodFn =
|
|
133
117
|
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
|
|
134
118
|
request({ ...options, method });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QuerySerializer } from './bodySerializer';
|
|
1
|
+
import type { BodySerializer, QuerySerializer } from './bodySerializer';
|
|
2
2
|
import {
|
|
3
3
|
type ArraySeparatorStyle,
|
|
4
4
|
serializeArrayParam,
|
|
@@ -110,3 +110,32 @@ export const getUrl = ({
|
|
|
110
110
|
}
|
|
111
111
|
return url;
|
|
112
112
|
};
|
|
113
|
+
|
|
114
|
+
export function getValidRequestBody(options: {
|
|
115
|
+
body?: unknown;
|
|
116
|
+
bodySerializer?: BodySerializer | null;
|
|
117
|
+
serializedBody?: unknown;
|
|
118
|
+
}) {
|
|
119
|
+
const hasBody = options.body !== undefined;
|
|
120
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
121
|
+
|
|
122
|
+
if (isSerializedBody) {
|
|
123
|
+
if ('serializedBody' in options) {
|
|
124
|
+
const hasSerializedBody =
|
|
125
|
+
options.serializedBody !== undefined && options.serializedBody !== '';
|
|
126
|
+
|
|
127
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// not all clients implement a serializedBody property (i.e. client-axios)
|
|
131
|
+
return options.body !== '' ? options.body : null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// plain/text body
|
|
135
|
+
if (hasBody) {
|
|
136
|
+
return options.body;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// no body was provided
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSseClient } from '../core/serverSentEvents';
|
|
2
2
|
import type { HttpMethod } from '../core/types';
|
|
3
|
+
import { getValidRequestBody } from '../core/utils';
|
|
3
4
|
import type {
|
|
4
5
|
Client,
|
|
5
6
|
Config,
|
|
@@ -210,26 +211,6 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
210
211
|
};
|
|
211
212
|
};
|
|
212
213
|
|
|
213
|
-
function getValidRequestBody(options: ResolvedRequestOptions) {
|
|
214
|
-
const hasBody = options.body !== undefined;
|
|
215
|
-
const isSerializedBody = hasBody && options.bodySerializer;
|
|
216
|
-
|
|
217
|
-
if (isSerializedBody) {
|
|
218
|
-
const hasSerializedBody =
|
|
219
|
-
options.serializedBody !== undefined && options.serializedBody !== '';
|
|
220
|
-
|
|
221
|
-
return hasSerializedBody ? options.serializedBody : null;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// plain/text body
|
|
225
|
-
if (hasBody) {
|
|
226
|
-
return options.body;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// no body was provided
|
|
230
|
-
return undefined;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
214
|
const makeMethodFn =
|
|
234
215
|
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
|
|
235
216
|
request({ ...options, method });
|
|
@@ -181,17 +181,27 @@ export const mergeConfigs = (a: Config, b: Config): Config => {
|
|
|
181
181
|
return config;
|
|
182
182
|
};
|
|
183
183
|
|
|
184
|
+
const headersEntries = (headers: Headers): Array<[string, string]> => {
|
|
185
|
+
const entries: Array<[string, string]> = [];
|
|
186
|
+
headers.forEach((value, key) => {
|
|
187
|
+
entries.push([key, value]);
|
|
188
|
+
});
|
|
189
|
+
return entries;
|
|
190
|
+
};
|
|
191
|
+
|
|
184
192
|
export const mergeHeaders = (
|
|
185
193
|
...headers: Array<Required<Config>['headers'] | undefined>
|
|
186
194
|
): Headers => {
|
|
187
195
|
const mergedHeaders = new Headers();
|
|
188
196
|
for (const header of headers) {
|
|
189
|
-
if (!header
|
|
197
|
+
if (!header) {
|
|
190
198
|
continue;
|
|
191
199
|
}
|
|
192
200
|
|
|
193
201
|
const iterator =
|
|
194
|
-
header instanceof Headers
|
|
202
|
+
header instanceof Headers
|
|
203
|
+
? headersEntries(header)
|
|
204
|
+
: Object.entries(header);
|
|
195
205
|
|
|
196
206
|
for (const [key, value] of iterator) {
|
|
197
207
|
if (value === null) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSseClient } from '../core/serverSentEvents';
|
|
2
2
|
import type { HttpMethod } from '../core/types';
|
|
3
|
+
import { getValidRequestBody } from '../core/utils';
|
|
3
4
|
import type {
|
|
4
5
|
Client,
|
|
5
6
|
Config,
|
|
@@ -198,26 +199,6 @@ export const createClient = (config: Config = {}): Client => {
|
|
|
198
199
|
};
|
|
199
200
|
};
|
|
200
201
|
|
|
201
|
-
function getValidRequestBody(options: ResolvedRequestOptions) {
|
|
202
|
-
const hasBody = options.body !== undefined;
|
|
203
|
-
const isSerializedBody = hasBody && options.bodySerializer;
|
|
204
|
-
|
|
205
|
-
if (isSerializedBody) {
|
|
206
|
-
const hasSerializedBody =
|
|
207
|
-
options.serializedBody !== undefined && options.serializedBody !== '';
|
|
208
|
-
|
|
209
|
-
return hasSerializedBody ? options.serializedBody : null;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// plain/text body
|
|
213
|
-
if (hasBody) {
|
|
214
|
-
return options.body;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// no body was provided
|
|
218
|
-
return undefined;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
202
|
const makeMethodFn =
|
|
222
203
|
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
|
|
223
204
|
request({ ...options, method });
|
|
@@ -293,6 +293,14 @@ export const mergeConfigs = (a: Config, b: Config): Config => {
|
|
|
293
293
|
return config;
|
|
294
294
|
};
|
|
295
295
|
|
|
296
|
+
const headersEntries = (headers: Headers): Array<[string, string]> => {
|
|
297
|
+
const entries: Array<[string, string]> = [];
|
|
298
|
+
headers.forEach((value, key) => {
|
|
299
|
+
entries.push([key, value]);
|
|
300
|
+
});
|
|
301
|
+
return entries;
|
|
302
|
+
};
|
|
303
|
+
|
|
296
304
|
export const mergeHeaders = (
|
|
297
305
|
...headers: Array<Required<Config>['headers'] | undefined>
|
|
298
306
|
): Headers => {
|
|
@@ -303,7 +311,9 @@ export const mergeHeaders = (
|
|
|
303
311
|
}
|
|
304
312
|
|
|
305
313
|
const iterator =
|
|
306
|
-
header instanceof Headers
|
|
314
|
+
header instanceof Headers
|
|
315
|
+
? headersEntries(header)
|
|
316
|
+
: Object.entries(header);
|
|
307
317
|
|
|
308
318
|
for (const [key, value] of iterator) {
|
|
309
319
|
if (value === null) {
|
|
@@ -250,6 +250,14 @@ export const mergeConfigs = (a: Config, b: Config): Config => {
|
|
|
250
250
|
return config;
|
|
251
251
|
};
|
|
252
252
|
|
|
253
|
+
const headersEntries = (headers: Headers): Array<[string, string]> => {
|
|
254
|
+
const entries: Array<[string, string]> = [];
|
|
255
|
+
headers.forEach((value, key) => {
|
|
256
|
+
entries.push([key, value]);
|
|
257
|
+
});
|
|
258
|
+
return entries;
|
|
259
|
+
};
|
|
260
|
+
|
|
253
261
|
export const mergeHeaders = (
|
|
254
262
|
...headers: Array<Required<Config>['headers'] | undefined>
|
|
255
263
|
): Headers => {
|
|
@@ -266,7 +274,7 @@ export const mergeHeaders = (
|
|
|
266
274
|
|
|
267
275
|
const iterator =
|
|
268
276
|
h instanceof Headers
|
|
269
|
-
? h
|
|
277
|
+
? headersEntries(h)
|
|
270
278
|
: Object.entries(h as Record<string, unknown>);
|
|
271
279
|
|
|
272
280
|
for (const [key, value] of iterator) {
|