File tree Expand file tree Collapse file tree 6 files changed +85
-3
lines changed Expand file tree Collapse file tree 6 files changed +85
-3
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export const getResponseBody = async (response: Response): Promise<any> => {
9
9
const isBinary = binaryTypes.some(type => contentType.toLowerCase().startsWith(type));
10
10
if (isJSON) {
11
11
return await response.json();
12
- } else if (isBinary) {}
12
+ } else if (isBinary) {
13
13
return await response.blob();
14
14
} else {
15
15
return await response.text();
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export const getResponseBody = async (response: Response): Promise<any> => {
9
9
const isBinary = binaryTypes.some(type => contentType.toLowerCase().startsWith(type));
10
10
if (isJSON) {
11
11
return await response.json();
12
- } else if (isBinary) {}
12
+ } else if (isBinary) {
13
13
return await response.blob();
14
14
} else {
15
15
return await response.text();
Original file line number Diff line number Diff line change @@ -4393,6 +4393,7 @@ export { DeprecatedService } from './services/DeprecatedService';
4393
4393
export { DescriptionsService } from './services/DescriptionsService';
4394
4394
export { DuplicateService } from './services/DuplicateService';
4395
4395
export { ErrorService } from './services/ErrorService';
4396
+ export { FileResponseService } from './services/FileResponseService';
4396
4397
export { FormDataService } from './services/FormDataService';
4397
4398
export { HeaderService } from './services/HeaderService';
4398
4399
export { MultipartService } from './services/MultipartService';
@@ -7595,6 +7596,30 @@ export class ErrorService {
7595
7596
"
7596
7597
`;
7597
7598
7599
+ exports[`v3 should generate: test/generated/v3/services/FileResponseService.ts 1`] = `
7600
+ "import type { CancelablePromise } from '../core/CancelablePromise';
7601
+ import { OpenAPI } from '../core/OpenAPI';
7602
+ import { request as __request } from '../core/request';
7603
+
7604
+ export class FileResponseService {
7605
+ /**
7606
+ * @param id
7607
+ * @returns binary Success
7608
+ * @throws ApiError
7609
+ */
7610
+ public static fileResponse(id: string): CancelablePromise<Blob> {
7611
+ return __request(OpenAPI, {
7612
+ method: 'GET',
7613
+ url: '/api/v{api-version}/file/{id}',
7614
+ path: {
7615
+ id: id,
7616
+ },
7617
+ });
7618
+ }
7619
+ }
7620
+ "
7621
+ `;
7622
+
7598
7623
exports[`v3 should generate: test/generated/v3/services/FormDataService.ts 1`] = `
7599
7624
"import type { ModelWithString } from '../models/ModelWithString';
7600
7625
import type { CancelablePromise } from '../core/CancelablePromise';
Original file line number Diff line number Diff line change @@ -75,6 +75,14 @@ describe('v3.fetch', () => {
75
75
expect ( result ) . toBeDefined ( ) ;
76
76
} ) ;
77
77
78
+ it ( 'support blob response data' , async ( ) => {
79
+ const result = await browser . evaluate ( async ( ) => {
80
+ const { FileResponseService } = ( window as any ) . api ;
81
+ return await FileResponseService . fileResponse ( 'test' ) ;
82
+ } ) ;
83
+ expect ( result ) . toBeDefined ( ) ;
84
+ } ) ;
85
+
78
86
it ( 'can abort the request' , async ( ) => {
79
87
let error ;
80
88
try {
Original file line number Diff line number Diff line change @@ -62,6 +62,12 @@ describe('v3.node', () => {
62
62
expect ( result ) . toBeDefined ( ) ;
63
63
} ) ;
64
64
65
+ it ( 'support blob response data' , async ( ) => {
66
+ const { FileResponseService } = require ( './generated/v3/node/index.js' ) ;
67
+ const result = await FileResponseService . fileResponse ( 'test' ) ;
68
+ expect ( result ) . toBeDefined ( ) ;
69
+ } ) ;
70
+
65
71
it ( 'can abort the request' , async ( ) => {
66
72
let error ;
67
73
try {
Original file line number Diff line number Diff line change 1229
1229
}
1230
1230
}
1231
1231
},
1232
+ "/api/v{api-version}/file/{id}" : {
1233
+ "get" : {
1234
+ "tags" : [
1235
+ " FileResponse"
1236
+ ],
1237
+ "operationId" : " FileResponse" ,
1238
+ "parameters" : [
1239
+ {
1240
+ "name" : " id" ,
1241
+ "in" : " path" ,
1242
+ "required" : true ,
1243
+ "schema" : {
1244
+ "type" : " string"
1245
+ }
1246
+ },
1247
+ {
1248
+ "name" : " api-version" ,
1249
+ "in" : " path" ,
1250
+ "required" : true ,
1251
+ "schema" : {
1252
+ "type" : " string"
1253
+ }
1254
+ }
1255
+ ],
1256
+ "responses" : {
1257
+ "200" : {
1258
+ "description" : " Success" ,
1259
+ "content" : {
1260
+ "audio/*" : {
1261
+ "schema" : {
1262
+ "type" : " file"
1263
+ }
1264
+ },
1265
+ "video/*" : {
1266
+ "schema" : {
1267
+ "type" : " file"
1268
+ }
1269
+ }
1270
+ }
1271
+ }
1272
+ }
1273
+ }
1274
+ },
1232
1275
"/api/v{api-version}/complex" : {
1233
1276
"get" : {
1234
1277
"tags" : [
3135
3178
}
3136
3179
}
3137
3180
}
3138
- }
3181
+ }
You can’t perform that action at this time.
0 commit comments