@@ -35,6 +35,7 @@ export type ApiRequestOptions = {
35
35
readonly query?: Record<string, any>;
36
36
readonly formData?: Record<string, any>;
37
37
readonly body?: any;
38
+ readonly bodyMediaType?: string;
38
39
readonly responseHeader?: string;
39
40
readonly errors?: Record<number, string>;
40
41
}"
@@ -180,12 +181,16 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
180
181
}
181
182
182
183
if (options.body) {
183
- if (isBlob(options.body)) {
184
- headers.append('Content-Type', options.body.type || 'application/octet-stream');
185
- } else if (isString(options.body)) {
186
- headers.append('Content-Type', 'text/plain');
184
+ if (options.bodyMediaType) {
185
+ headers.append('Content-Type', options.bodyMediaType);
187
186
} else {
188
- headers.append('Content-Type', 'application/json');
187
+ if (isBlob(options.body)) {
188
+ headers.append('Content-Type', options.body.type || 'application/octet-stream');
189
+ } else if (isString(options.body)) {
190
+ headers.append('Content-Type', 'text/plain');
191
+ } else {
192
+ headers.append('Content-Type', 'application/json');
193
+ }
189
194
}
190
195
}
191
196
return headers;
@@ -196,7 +201,9 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
196
201
return getFormData(options.formData);
197
202
}
198
203
if (options.body) {
199
- if (isString(options.body) || isBlob(options.body)) {
204
+ if (options.bodyMediaType?.includes('/json')) {
205
+ return JSON.stringify(options.body)
206
+ } else if (isString(options.body) || isBlob(options.body)) {
200
207
return options.body;
201
208
} else {
202
209
return JSON.stringify(options.body);
@@ -2383,6 +2390,7 @@ export type ApiRequestOptions = {
2383
2390
readonly query?: Record<string, any>;
2384
2391
readonly formData?: Record<string, any>;
2385
2392
readonly body?: any;
2393
+ readonly bodyMediaType?: string;
2386
2394
readonly responseHeader?: string;
2387
2395
readonly errors?: Record<number, string>;
2388
2396
}"
@@ -2528,12 +2536,16 @@ async function getHeaders(options: ApiRequestOptions): Promise<Headers> {
2528
2536
}
2529
2537
2530
2538
if (options.body) {
2531
- if (isBlob(options.body)) {
2532
- headers.append('Content-Type', options.body.type || 'application/octet-stream');
2533
- } else if (isString(options.body)) {
2534
- headers.append('Content-Type', 'text/plain');
2539
+ if (options.bodyMediaType) {
2540
+ headers.append('Content-Type', options.bodyMediaType);
2535
2541
} else {
2536
- headers.append('Content-Type', 'application/json');
2542
+ if (isBlob(options.body)) {
2543
+ headers.append('Content-Type', options.body.type || 'application/octet-stream');
2544
+ } else if (isString(options.body)) {
2545
+ headers.append('Content-Type', 'text/plain');
2546
+ } else {
2547
+ headers.append('Content-Type', 'application/json');
2548
+ }
2537
2549
}
2538
2550
}
2539
2551
return headers;
@@ -2544,7 +2556,9 @@ function getRequestBody(options: ApiRequestOptions): BodyInit | undefined {
2544
2556
return getFormData(options.formData);
2545
2557
}
2546
2558
if (options.body) {
2547
- if (isString(options.body) || isBlob(options.body)) {
2559
+ if (options.bodyMediaType?.includes('/json')) {
2560
+ return JSON.stringify(options.body)
2561
+ } else if (isString(options.body) || isBlob(options.body)) {
2548
2562
return options.body;
2549
2563
} else {
2550
2564
return JSON.stringify(options.body);
@@ -4481,6 +4495,7 @@ export class ComplexService {
4481
4495
method: 'PUT',
4482
4496
path: \`/api/v\${OpenAPI.VERSION}/complex/\${id}\`,
4483
4497
body: requestBody,
4498
+ bodyMediaType: 'application/json-patch+json',
4484
4499
});
4485
4500
return result.body;
4486
4501
}
@@ -4777,6 +4792,7 @@ export class ParametersService {
4777
4792
'parameterForm': parameterForm,
4778
4793
},
4779
4794
body: requestBody,
4795
+ bodyMediaType: 'application/json',
4780
4796
});
4781
4797
return result.body;
4782
4798
}
@@ -4821,6 +4837,7 @@ export class ParametersService {
4821
4837
'parameter_form': parameterForm,
4822
4838
},
4823
4839
body: requestBody,
4840
+ bodyMediaType: 'application/json',
4824
4841
});
4825
4842
return result.body;
4826
4843
}
@@ -4841,6 +4858,7 @@ export class ParametersService {
4841
4858
'parameter': parameter,
4842
4859
},
4843
4860
body: requestBody,
4861
+ bodyMediaType: 'application/json',
4844
4862
});
4845
4863
return result.body;
4846
4864
}
@@ -4861,6 +4879,7 @@ export class ParametersService {
4861
4879
'parameter': parameter,
4862
4880
},
4863
4881
body: requestBody,
4882
+ bodyMediaType: 'application/json',
4864
4883
});
4865
4884
return result.body;
4866
4885
}
@@ -4889,6 +4908,7 @@ export class RequestBodyService {
4889
4908
method: 'POST',
4890
4909
path: \`/api/v\${OpenAPI.VERSION}/requestBody/\`,
4891
4910
body: requestBody,
4911
+ bodyMediaType: 'application/json',
4892
4912
});
4893
4913
return result.body;
4894
4914
}
0 commit comments