Skip to content

Commit 391ced3

Browse files
authored
Merge branch 'main' into volesen/node-compatible-mergeHeaders
2 parents debba72 + ec26321 commit 391ced3

File tree

260 files changed

+5002
-1027
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

260 files changed

+5002
-1027
lines changed

docs/openapi-ts/clients/nuxt.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ Interceptors (middleware) can be used to modify requests before they're sent or
175175

176176
You can pass any Nuxt/ofetch arguments to the client instance.
177177

178+
::: tip
179+
If you omit `composable`, `$fetch` is used by default.
180+
:::
181+
178182
```js
179183
import { client } from 'client/client.gen';
180184

docs/partials/contributors-list.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- [Daschi](https://github.com/Daschi1)
1818
- [David Bieregger](https://github.com/BierDav)
1919
- [David Ovčačík](https://github.com/dovca)
20+
- [Dmitriy Brolnickij](https://github.com/brolnickij)
2021
- [Finn Poppinga](https://github.com/fpoppinga)
2122
- [Florian Lutze](https://github.com/flow96)
2223
- [Francisco García](https://github.com/goltra)

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ export const createClient = (config: Config = {}): Client => {
6060
await opts.requestValidator(opts);
6161
}
6262

63-
if (opts.body && opts.bodySerializer) {
63+
if (opts.body !== undefined && opts.bodySerializer) {
6464
opts.serializedBody = opts.bodySerializer(opts.body);
6565
}
6666

6767
// remove Content-Type header if body is empty to avoid sending invalid requests
68-
if (opts.serializedBody === undefined || opts.serializedBody === '') {
68+
if (opts.body === undefined || opts.serializedBody === '') {
6969
opts.headers.delete('Content-Type');
7070
}
7171

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const requestInit: ReqInit = {
8181
redirect: 'follow',
8282
...opts,
83-
body: opts.serializedBody,
83+
body: getValidRequestBody(opts),
8484
};
8585

8686
let request = new Request(url, requestInit);
@@ -212,6 +212,26 @@ export const createClient = (config: Config = {}): Client => {
212212
};
213213
};
214214

215+
function getValidRequestBody(options: ResolvedRequestOptions) {
216+
const hasBody = options.body !== undefined;
217+
const isSerializedBody = hasBody && options.bodySerializer;
218+
219+
if (isSerializedBody) {
220+
const hasSerializedBody =
221+
options.serializedBody !== undefined && options.serializedBody !== '';
222+
223+
return hasSerializedBody ? options.serializedBody : null;
224+
}
225+
226+
// plain/text body
227+
if (hasBody) {
228+
return options.body;
229+
}
230+
231+
// no body was provided
232+
return undefined;
233+
}
234+
215235
const makeMethodFn =
216236
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
217237
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ export const createClient = (config: Config = {}): Client => {
6060
await opts.requestValidator(opts);
6161
}
6262

63-
if (opts.body && opts.bodySerializer) {
63+
if (opts.body !== undefined && opts.bodySerializer) {
6464
opts.serializedBody = opts.bodySerializer(opts.body);
6565
}
6666

6767
// remove Content-Type header if body is empty to avoid sending invalid requests
68-
if (opts.serializedBody === undefined || opts.serializedBody === '') {
68+
if (opts.body === undefined || opts.serializedBody === '') {
6969
opts.headers.delete('Content-Type');
7070
}
7171

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const requestInit: ReqInit = {
8181
redirect: 'follow',
8282
...opts,
83-
body: opts.serializedBody,
83+
body: getValidRequestBody(opts),
8484
};
8585

8686
let request = new Request(url, requestInit);
@@ -212,6 +212,26 @@ export const createClient = (config: Config = {}): Client => {
212212
};
213213
};
214214

215+
function getValidRequestBody(options: ResolvedRequestOptions) {
216+
const hasBody = options.body !== undefined;
217+
const isSerializedBody = hasBody && options.bodySerializer;
218+
219+
if (isSerializedBody) {
220+
const hasSerializedBody =
221+
options.serializedBody !== undefined && options.serializedBody !== '';
222+
223+
return hasSerializedBody ? options.serializedBody : null;
224+
}
225+
226+
// plain/text body
227+
if (hasBody) {
228+
return options.body;
229+
}
230+
231+
// no body was provided
232+
return undefined;
233+
}
234+
215235
const makeMethodFn =
216236
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
217237
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ export const createClient = (config: Config = {}): Client => {
6060
await opts.requestValidator(opts);
6161
}
6262

63-
if (opts.body && opts.bodySerializer) {
63+
if (opts.body !== undefined && opts.bodySerializer) {
6464
opts.serializedBody = opts.bodySerializer(opts.body);
6565
}
6666

6767
// remove Content-Type header if body is empty to avoid sending invalid requests
68-
if (opts.serializedBody === undefined || opts.serializedBody === '') {
68+
if (opts.body === undefined || opts.serializedBody === '') {
6969
opts.headers.delete('Content-Type');
7070
}
7171

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const requestInit: ReqInit = {
8181
redirect: 'follow',
8282
...opts,
83-
body: opts.serializedBody,
83+
body: getValidRequestBody(opts),
8484
};
8585

8686
let request = new Request(url, requestInit);
@@ -212,6 +212,26 @@ export const createClient = (config: Config = {}): Client => {
212212
};
213213
};
214214

215+
function getValidRequestBody(options: ResolvedRequestOptions) {
216+
const hasBody = options.body !== undefined;
217+
const isSerializedBody = hasBody && options.bodySerializer;
218+
219+
if (isSerializedBody) {
220+
const hasSerializedBody =
221+
options.serializedBody !== undefined && options.serializedBody !== '';
222+
223+
return hasSerializedBody ? options.serializedBody : null;
224+
}
225+
226+
// plain/text body
227+
if (hasBody) {
228+
return options.body;
229+
}
230+
231+
// no body was provided
232+
return undefined;
233+
}
234+
215235
const makeMethodFn =
216236
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
217237
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ export const createClient = (config: Config = {}): Client => {
6060
await opts.requestValidator(opts);
6161
}
6262

63-
if (opts.body && opts.bodySerializer) {
63+
if (opts.body !== undefined && opts.bodySerializer) {
6464
opts.serializedBody = opts.bodySerializer(opts.body);
6565
}
6666

6767
// remove Content-Type header if body is empty to avoid sending invalid requests
68-
if (opts.serializedBody === undefined || opts.serializedBody === '') {
68+
if (opts.body === undefined || opts.serializedBody === '') {
6969
opts.headers.delete('Content-Type');
7070
}
7171

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const requestInit: ReqInit = {
8181
redirect: 'follow',
8282
...opts,
83-
body: opts.serializedBody,
83+
body: getValidRequestBody(opts),
8484
};
8585

8686
let request = new Request(url, requestInit);
@@ -212,6 +212,26 @@ export const createClient = (config: Config = {}): Client => {
212212
};
213213
};
214214

215+
function getValidRequestBody(options: ResolvedRequestOptions) {
216+
const hasBody = options.body !== undefined;
217+
const isSerializedBody = hasBody && options.bodySerializer;
218+
219+
if (isSerializedBody) {
220+
const hasSerializedBody =
221+
options.serializedBody !== undefined && options.serializedBody !== '';
222+
223+
return hasSerializedBody ? options.serializedBody : null;
224+
}
225+
226+
// plain/text body
227+
if (hasBody) {
228+
return options.body;
229+
}
230+
231+
// no body was provided
232+
return undefined;
233+
}
234+
215235
const makeMethodFn =
216236
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
217237
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ export const createClient = (config: Config = {}): Client => {
6060
await opts.requestValidator(opts);
6161
}
6262

63-
if (opts.body && opts.bodySerializer) {
63+
if (opts.body !== undefined && opts.bodySerializer) {
6464
opts.serializedBody = opts.bodySerializer(opts.body);
6565
}
6666

6767
// remove Content-Type header if body is empty to avoid sending invalid requests
68-
if (opts.serializedBody === undefined || opts.serializedBody === '') {
68+
if (opts.body === undefined || opts.serializedBody === '') {
6969
opts.headers.delete('Content-Type');
7070
}
7171

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const requestInit: ReqInit = {
8181
redirect: 'follow',
8282
...opts,
83-
body: opts.serializedBody,
83+
body: getValidRequestBody(opts),
8484
};
8585

8686
let request = new Request(url, requestInit);
@@ -212,6 +212,26 @@ export const createClient = (config: Config = {}): Client => {
212212
};
213213
};
214214

215+
function getValidRequestBody(options: ResolvedRequestOptions) {
216+
const hasBody = options.body !== undefined;
217+
const isSerializedBody = hasBody && options.bodySerializer;
218+
219+
if (isSerializedBody) {
220+
const hasSerializedBody =
221+
options.serializedBody !== undefined && options.serializedBody !== '';
222+
223+
return hasSerializedBody ? options.serializedBody : null;
224+
}
225+
226+
// plain/text body
227+
if (hasBody) {
228+
return options.body;
229+
}
230+
231+
// no body was provided
232+
return undefined;
233+
}
234+
215235
const makeMethodFn =
216236
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
217237
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ export const createClient = (config: Config = {}): Client => {
6060
await opts.requestValidator(opts);
6161
}
6262

63-
if (opts.body && opts.bodySerializer) {
63+
if (opts.body !== undefined && opts.bodySerializer) {
6464
opts.serializedBody = opts.bodySerializer(opts.body);
6565
}
6666

6767
// remove Content-Type header if body is empty to avoid sending invalid requests
68-
if (opts.serializedBody === undefined || opts.serializedBody === '') {
68+
if (opts.body === undefined || opts.serializedBody === '') {
6969
opts.headers.delete('Content-Type');
7070
}
7171

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const requestInit: ReqInit = {
8181
redirect: 'follow',
8282
...opts,
83-
body: opts.serializedBody,
83+
body: getValidRequestBody(opts),
8484
};
8585

8686
let request = new Request(url, requestInit);
@@ -212,6 +212,26 @@ export const createClient = (config: Config = {}): Client => {
212212
};
213213
};
214214

215+
function getValidRequestBody(options: ResolvedRequestOptions) {
216+
const hasBody = options.body !== undefined;
217+
const isSerializedBody = hasBody && options.bodySerializer;
218+
219+
if (isSerializedBody) {
220+
const hasSerializedBody =
221+
options.serializedBody !== undefined && options.serializedBody !== '';
222+
223+
return hasSerializedBody ? options.serializedBody : null;
224+
}
225+
226+
// plain/text body
227+
if (hasBody) {
228+
return options.body;
229+
}
230+
231+
// no body was provided
232+
return undefined;
233+
}
234+
215235
const makeMethodFn =
216236
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
217237
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ export const createClient = (config: Config = {}): Client => {
6060
await opts.requestValidator(opts);
6161
}
6262

63-
if (opts.body && opts.bodySerializer) {
63+
if (opts.body !== undefined && opts.bodySerializer) {
6464
opts.serializedBody = opts.bodySerializer(opts.body);
6565
}
6666

6767
// remove Content-Type header if body is empty to avoid sending invalid requests
68-
if (opts.serializedBody === undefined || opts.serializedBody === '') {
68+
if (opts.body === undefined || opts.serializedBody === '') {
6969
opts.headers.delete('Content-Type');
7070
}
7171

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const requestInit: ReqInit = {
8181
redirect: 'follow',
8282
...opts,
83-
body: opts.serializedBody,
83+
body: getValidRequestBody(opts),
8484
};
8585

8686
let request = new Request(url, requestInit);
@@ -212,6 +212,26 @@ export const createClient = (config: Config = {}): Client => {
212212
};
213213
};
214214

215+
function getValidRequestBody(options: ResolvedRequestOptions) {
216+
const hasBody = options.body !== undefined;
217+
const isSerializedBody = hasBody && options.bodySerializer;
218+
219+
if (isSerializedBody) {
220+
const hasSerializedBody =
221+
options.serializedBody !== undefined && options.serializedBody !== '';
222+
223+
return hasSerializedBody ? options.serializedBody : null;
224+
}
225+
226+
// plain/text body
227+
if (hasBody) {
228+
return options.body;
229+
}
230+
231+
// no body was provided
232+
return undefined;
233+
}
234+
215235
const makeMethodFn =
216236
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
217237
request({ ...options, method });

0 commit comments

Comments
 (0)