Skip to content

Commit a4e38ad

Browse files
committed
update snapshots
1 parent 2a9141b commit a4e38ad

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/__snapshots__/index.spec.ts.snap

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export type ApiRequestOptions = {
3838
readonly formData?: Record<string, any>;
3939
readonly body?: any;
4040
readonly mediaType?: string;
41+
readonly responseType?: 'blob';
4142
readonly responseHeader?: string;
4243
readonly errors?: Record<number, string>;
4344
};"
@@ -450,14 +451,16 @@ const getResponseHeader = (response: Response, responseHeader?: string): string
450451
return undefined;
451452
};
452453

453-
const getResponseBody = async (response: Response): Promise<any> => {
454+
const getResponseBody = async (response: Response, options: ApiRequestOptions): Promise<any> => {
454455
if (response.status !== 204) {
455456
try {
456457
const contentType = response.headers.get('Content-Type');
457458
if (contentType) {
458459
const isJSON = contentType.toLowerCase().startsWith('application/json');
459460
if (isJSON) {
460461
return await response.json();
462+
} else if (options.responseType === 'blob') {
463+
return await response.blob();
461464
} else {
462465
return await response.text();
463466
}
@@ -508,7 +511,7 @@ export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions): C
508511

509512
if (!onCancel.isCancelled) {
510513
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
511-
const responseBody = await getResponseBody(response);
514+
const responseBody = await getResponseBody(response, options);
512515
const responseHeader = getResponseHeader(response, options.responseHeader);
513516

514517
const result: ApiResult = {
@@ -2978,6 +2981,7 @@ export type ApiRequestOptions = {
29782981
readonly formData?: Record<string, any>;
29792982
readonly body?: any;
29802983
readonly mediaType?: string;
2984+
readonly responseType?: 'blob';
29812985
readonly responseHeader?: string;
29822986
readonly errors?: Record<number, string>;
29832987
};"
@@ -3390,14 +3394,16 @@ const getResponseHeader = (response: Response, responseHeader?: string): string
33903394
return undefined;
33913395
};
33923396

3393-
const getResponseBody = async (response: Response): Promise<any> => {
3397+
const getResponseBody = async (response: Response, options: ApiRequestOptions): Promise<any> => {
33943398
if (response.status !== 204) {
33953399
try {
33963400
const contentType = response.headers.get('Content-Type');
33973401
if (contentType) {
33983402
const isJSON = contentType.toLowerCase().startsWith('application/json');
33993403
if (isJSON) {
34003404
return await response.json();
3405+
} else if (options.responseType === 'blob') {
3406+
return await response.blob();
34013407
} else {
34023408
return await response.text();
34033409
}
@@ -3448,7 +3454,7 @@ export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions): C
34483454

34493455
if (!onCancel.isCancelled) {
34503456
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
3451-
const responseBody = await getResponseBody(response);
3457+
const responseBody = await getResponseBody(response, options);
34523458
const responseHeader = getResponseHeader(response, options.responseHeader);
34533459

34543460
const result: ApiResult = {

0 commit comments

Comments
 (0)