Skip to content

Commit 7048a91

Browse files
author
Fransis Young
committed
chore(client): updates snapshots
refs: #2599
1 parent c15b19a commit 7048a91

File tree

29 files changed

+551
-58
lines changed

29 files changed

+551
-58
lines changed

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const createClient = (config: Config = {}): Client => {
5959
await opts.requestValidator(opts);
6060
}
6161

62-
if (opts.body && opts.bodySerializer) {
62+
if (opts.body !== undefined && opts.bodySerializer) {
6363
opts.body = opts.bodySerializer(opts.body);
6464
}
6565

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const response = await _axios({
8181
...optsWithoutAuth,
8282
baseURL: opts.baseURL as string,
83-
data: opts.body,
83+
data: getValidRequestBody(opts),
8484
headers: opts.headers as RawAxiosRequestHeaders,
8585
// let `paramsSerializer()` handle query params if it exists
8686
params: opts.paramsSerializer ? opts.query : undefined,
@@ -114,6 +114,23 @@ export const createClient = (config: Config = {}): Client => {
114114
}
115115
};
116116

117+
function getValidRequestBody(options: RequestOptions) {
118+
const hasBody = options.body !== undefined;
119+
const isSerializedBody = hasBody && options.bodySerializer;
120+
121+
if (isSerializedBody) {
122+
return options.body !== '' ? options.body : null;
123+
}
124+
125+
// plain/text body
126+
if (hasBody) {
127+
return options.body;
128+
}
129+
130+
// no body was provided
131+
return undefined;
132+
}
133+
117134
const makeMethodFn =
118135
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
119136
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/client/client.gen.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const createClient = (config: Config = {}): Client => {
5959
await opts.requestValidator(opts);
6060
}
6161

62-
if (opts.body && opts.bodySerializer) {
62+
if (opts.body !== undefined && opts.bodySerializer) {
6363
opts.body = opts.bodySerializer(opts.body);
6464
}
6565

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const response = await _axios({
8181
...optsWithoutAuth,
8282
baseURL: opts.baseURL as string,
83-
data: opts.body,
83+
data: getValidRequestBody(opts),
8484
headers: opts.headers as RawAxiosRequestHeaders,
8585
// let `paramsSerializer()` handle query params if it exists
8686
params: opts.paramsSerializer ? opts.query : undefined,
@@ -114,6 +114,23 @@ export const createClient = (config: Config = {}): Client => {
114114
}
115115
};
116116

117+
function getValidRequestBody(options: RequestOptions) {
118+
const hasBody = options.body !== undefined;
119+
const isSerializedBody = hasBody && options.bodySerializer;
120+
121+
if (isSerializedBody) {
122+
return options.body !== '' ? options.body : null;
123+
}
124+
125+
// plain/text body
126+
if (hasBody) {
127+
return options.body;
128+
}
129+
130+
// no body was provided
131+
return undefined;
132+
}
133+
117134
const makeMethodFn =
118135
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
119136
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/client/client.gen.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const createClient = (config: Config = {}): Client => {
5959
await opts.requestValidator(opts);
6060
}
6161

62-
if (opts.body && opts.bodySerializer) {
62+
if (opts.body !== undefined && opts.bodySerializer) {
6363
opts.body = opts.bodySerializer(opts.body);
6464
}
6565

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const response = await _axios({
8181
...optsWithoutAuth,
8282
baseURL: opts.baseURL as string,
83-
data: opts.body,
83+
data: getValidRequestBody(opts),
8484
headers: opts.headers as RawAxiosRequestHeaders,
8585
// let `paramsSerializer()` handle query params if it exists
8686
params: opts.paramsSerializer ? opts.query : undefined,
@@ -114,6 +114,23 @@ export const createClient = (config: Config = {}): Client => {
114114
}
115115
};
116116

117+
function getValidRequestBody(options: RequestOptions) {
118+
const hasBody = options.body !== undefined;
119+
const isSerializedBody = hasBody && options.bodySerializer;
120+
121+
if (isSerializedBody) {
122+
return options.body !== '' ? options.body : null;
123+
}
124+
125+
// plain/text body
126+
if (hasBody) {
127+
return options.body;
128+
}
129+
130+
// no body was provided
131+
return undefined;
132+
}
133+
117134
const makeMethodFn =
118135
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
119136
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/client/client.gen.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const createClient = (config: Config = {}): Client => {
5959
await opts.requestValidator(opts);
6060
}
6161

62-
if (opts.body && opts.bodySerializer) {
62+
if (opts.body !== undefined && opts.bodySerializer) {
6363
opts.body = opts.bodySerializer(opts.body);
6464
}
6565

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const response = await _axios({
8181
...optsWithoutAuth,
8282
baseURL: opts.baseURL as string,
83-
data: opts.body,
83+
data: getValidRequestBody(opts),
8484
headers: opts.headers as RawAxiosRequestHeaders,
8585
// let `paramsSerializer()` handle query params if it exists
8686
params: opts.paramsSerializer ? opts.query : undefined,
@@ -114,6 +114,23 @@ export const createClient = (config: Config = {}): Client => {
114114
}
115115
};
116116

117+
function getValidRequestBody(options: RequestOptions) {
118+
const hasBody = options.body !== undefined;
119+
const isSerializedBody = hasBody && options.bodySerializer;
120+
121+
if (isSerializedBody) {
122+
return options.body !== '' ? options.body : null;
123+
}
124+
125+
// plain/text body
126+
if (hasBody) {
127+
return options.body;
128+
}
129+
130+
// no body was provided
131+
return undefined;
132+
}
133+
117134
const makeMethodFn =
118135
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
119136
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/client/client.gen.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const createClient = (config: Config = {}): Client => {
5959
await opts.requestValidator(opts);
6060
}
6161

62-
if (opts.body && opts.bodySerializer) {
62+
if (opts.body !== undefined && opts.bodySerializer) {
6363
opts.body = opts.bodySerializer(opts.body);
6464
}
6565

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const response = await _axios({
8181
...optsWithoutAuth,
8282
baseURL: opts.baseURL as string,
83-
data: opts.body,
83+
data: getValidRequestBody(opts),
8484
headers: opts.headers as RawAxiosRequestHeaders,
8585
// let `paramsSerializer()` handle query params if it exists
8686
params: opts.paramsSerializer ? opts.query : undefined,
@@ -114,6 +114,23 @@ export const createClient = (config: Config = {}): Client => {
114114
}
115115
};
116116

117+
function getValidRequestBody(options: RequestOptions) {
118+
const hasBody = options.body !== undefined;
119+
const isSerializedBody = hasBody && options.bodySerializer;
120+
121+
if (isSerializedBody) {
122+
return options.body !== '' ? options.body : null;
123+
}
124+
125+
// plain/text body
126+
if (hasBody) {
127+
return options.body;
128+
}
129+
130+
// no body was provided
131+
return undefined;
132+
}
133+
117134
const makeMethodFn =
118135
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
119136
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/client/client.gen.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const createClient = (config: Config = {}): Client => {
5959
await opts.requestValidator(opts);
6060
}
6161

62-
if (opts.body && opts.bodySerializer) {
62+
if (opts.body !== undefined && opts.bodySerializer) {
6363
opts.body = opts.bodySerializer(opts.body);
6464
}
6565

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const response = await _axios({
8181
...optsWithoutAuth,
8282
baseURL: opts.baseURL as string,
83-
data: opts.body,
83+
data: getValidRequestBody(opts),
8484
headers: opts.headers as RawAxiosRequestHeaders,
8585
// let `paramsSerializer()` handle query params if it exists
8686
params: opts.paramsSerializer ? opts.query : undefined,
@@ -114,6 +114,23 @@ export const createClient = (config: Config = {}): Client => {
114114
}
115115
};
116116

117+
function getValidRequestBody(options: RequestOptions) {
118+
const hasBody = options.body !== undefined;
119+
const isSerializedBody = hasBody && options.bodySerializer;
120+
121+
if (isSerializedBody) {
122+
return options.body !== '' ? options.body : null;
123+
}
124+
125+
// plain/text body
126+
if (hasBody) {
127+
return options.body;
128+
}
129+
130+
// no body was provided
131+
return undefined;
132+
}
133+
117134
const makeMethodFn =
118135
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
119136
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/client/client.gen.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const createClient = (config: Config = {}): Client => {
5959
await opts.requestValidator(opts);
6060
}
6161

62-
if (opts.body && opts.bodySerializer) {
62+
if (opts.body !== undefined && opts.bodySerializer) {
6363
opts.body = opts.bodySerializer(opts.body);
6464
}
6565

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const response = await _axios({
8181
...optsWithoutAuth,
8282
baseURL: opts.baseURL as string,
83-
data: opts.body,
83+
data: getValidRequestBody(opts),
8484
headers: opts.headers as RawAxiosRequestHeaders,
8585
// let `paramsSerializer()` handle query params if it exists
8686
params: opts.paramsSerializer ? opts.query : undefined,
@@ -114,6 +114,23 @@ export const createClient = (config: Config = {}): Client => {
114114
}
115115
};
116116

117+
function getValidRequestBody(options: RequestOptions) {
118+
const hasBody = options.body !== undefined;
119+
const isSerializedBody = hasBody && options.bodySerializer;
120+
121+
if (isSerializedBody) {
122+
return options.body !== '' ? options.body : null;
123+
}
124+
125+
// plain/text body
126+
if (hasBody) {
127+
return options.body;
128+
}
129+
130+
// no body was provided
131+
return undefined;
132+
}
133+
117134
const makeMethodFn =
118135
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
119136
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/client/client.gen.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const createClient = (config: Config = {}): Client => {
5959
await opts.requestValidator(opts);
6060
}
6161

62-
if (opts.body && opts.bodySerializer) {
62+
if (opts.body !== undefined && opts.bodySerializer) {
6363
opts.body = opts.bodySerializer(opts.body);
6464
}
6565

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const response = await _axios({
8181
...optsWithoutAuth,
8282
baseURL: opts.baseURL as string,
83-
data: opts.body,
83+
data: getValidRequestBody(opts),
8484
headers: opts.headers as RawAxiosRequestHeaders,
8585
// let `paramsSerializer()` handle query params if it exists
8686
params: opts.paramsSerializer ? opts.query : undefined,
@@ -114,6 +114,23 @@ export const createClient = (config: Config = {}): Client => {
114114
}
115115
};
116116

117+
function getValidRequestBody(options: RequestOptions) {
118+
const hasBody = options.body !== undefined;
119+
const isSerializedBody = hasBody && options.bodySerializer;
120+
121+
if (isSerializedBody) {
122+
return options.body !== '' ? options.body : null;
123+
}
124+
125+
// plain/text body
126+
if (hasBody) {
127+
return options.body;
128+
}
129+
130+
// no body was provided
131+
return undefined;
132+
}
133+
117134
const makeMethodFn =
118135
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
119136
request({ ...options, method });

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/client/client.gen.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const createClient = (config: Config = {}): Client => {
5959
await opts.requestValidator(opts);
6060
}
6161

62-
if (opts.body && opts.bodySerializer) {
62+
if (opts.body !== undefined && opts.bodySerializer) {
6363
opts.body = opts.bodySerializer(opts.body);
6464
}
6565

@@ -80,7 +80,7 @@ export const createClient = (config: Config = {}): Client => {
8080
const response = await _axios({
8181
...optsWithoutAuth,
8282
baseURL: opts.baseURL as string,
83-
data: opts.body,
83+
data: getValidRequestBody(opts),
8484
headers: opts.headers as RawAxiosRequestHeaders,
8585
// let `paramsSerializer()` handle query params if it exists
8686
params: opts.paramsSerializer ? opts.query : undefined,
@@ -114,6 +114,23 @@ export const createClient = (config: Config = {}): Client => {
114114
}
115115
};
116116

117+
function getValidRequestBody(options: RequestOptions) {
118+
const hasBody = options.body !== undefined;
119+
const isSerializedBody = hasBody && options.bodySerializer;
120+
121+
if (isSerializedBody) {
122+
return options.body !== '' ? options.body : null;
123+
}
124+
125+
// plain/text body
126+
if (hasBody) {
127+
return options.body;
128+
}
129+
130+
// no body was provided
131+
return undefined;
132+
}
133+
117134
const makeMethodFn =
118135
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
119136
request({ ...options, method });

0 commit comments

Comments
 (0)