@@ -56,6 +56,7 @@ export class ApiEndpoints {
5656 url : url ,
5757 method : "delete" ,
5858 headers : headers ,
59+ responseType : "arraybuffer" ,
5960 ...config ,
6061 } ) ;
6162
@@ -70,12 +71,13 @@ export class ApiEndpoints {
7071 contentType : contentType ,
7172 rawResponse : httpRes ,
7273 } ) ;
74+ const decodedRes = new TextDecoder ( ) . decode ( httpRes ?. data ) ;
7375 switch ( true ) {
7476 case httpRes ?. status == 200 :
7577 break ;
7678 default :
7779 if ( utils . matchContentType ( contentType , `application/json` ) ) {
78- res . error = utils . objectToClass ( httpRes ?. data , shared . ErrorT ) ;
80+ res . error = utils . objectToClass ( JSON . parse ( decodedRes ) , shared . ErrorT ) ;
7981 }
8082 break ;
8183 }
@@ -122,6 +124,7 @@ export class ApiEndpoints {
122124 url : url ,
123125 method : "get" ,
124126 headers : headers ,
127+ responseType : "arraybuffer" ,
125128 ...config ,
126129 } ) ;
127130
@@ -136,15 +139,19 @@ export class ApiEndpoints {
136139 contentType : contentType ,
137140 rawResponse : httpRes ,
138141 } ) ;
142+ const decodedRes = new TextDecoder ( ) . decode ( httpRes ?. data ) ;
139143 switch ( true ) {
140144 case httpRes ?. status == 200 :
141145 if ( utils . matchContentType ( contentType , `application/json` ) ) {
142- res . apiEndpoint = utils . objectToClass ( httpRes ?. data , shared . ApiEndpoint ) ;
146+ res . apiEndpoint = utils . objectToClass (
147+ JSON . parse ( decodedRes ) ,
148+ shared . ApiEndpoint
149+ ) ;
143150 }
144151 break ;
145152 default :
146153 if ( utils . matchContentType ( contentType , `application/json` ) ) {
147- res . error = utils . objectToClass ( httpRes ?. data , shared . ErrorT ) ;
154+ res . error = utils . objectToClass ( JSON . parse ( decodedRes ) , shared . ErrorT ) ;
148155 }
149156 break ;
150157 }
@@ -191,6 +198,7 @@ export class ApiEndpoints {
191198 url : url ,
192199 method : "get" ,
193200 headers : headers ,
201+ responseType : "arraybuffer" ,
194202 ...config ,
195203 } ) ;
196204
@@ -206,18 +214,19 @@ export class ApiEndpoints {
206214 contentType : contentType ,
207215 rawResponse : httpRes ,
208216 } ) ;
217+ const decodedRes = new TextDecoder ( ) . decode ( httpRes ?. data ) ;
209218 switch ( true ) {
210219 case httpRes ?. status == 200 :
211220 if ( utils . matchContentType ( contentType , `application/json` ) ) {
212221 res . generateOpenApiSpecDiff = utils . objectToClass (
213- httpRes ?. data ,
222+ JSON . parse ( decodedRes ) ,
214223 shared . GenerateOpenApiSpecDiff
215224 ) ;
216225 }
217226 break ;
218227 default :
219228 if ( utils . matchContentType ( contentType , `application/json` ) ) {
220- res . error = utils . objectToClass ( httpRes ?. data , shared . ErrorT ) ;
229+ res . error = utils . objectToClass ( JSON . parse ( decodedRes ) , shared . ErrorT ) ;
221230 }
222231 break ;
223232 }
@@ -263,6 +272,7 @@ export class ApiEndpoints {
263272 url : url ,
264273 method : "get" ,
265274 headers : headers ,
275+ responseType : "arraybuffer" ,
266276 ...config ,
267277 } ) ;
268278
@@ -278,18 +288,16 @@ export class ApiEndpoints {
278288 contentType : contentType ,
279289 rawResponse : httpRes ,
280290 } ) ;
291+ const decodedRes = new TextDecoder ( ) . decode ( httpRes ?. data ) ;
281292 switch ( true ) {
282293 case httpRes ?. status == 200 :
283294 if ( utils . matchContentType ( contentType , `application/octet-stream` ) ) {
284- const resBody : string = JSON . stringify ( httpRes ?. data , null , 0 ) ;
285- const out : Uint8Array = new Uint8Array ( resBody . length ) ;
286- for ( let i = 0 ; i < resBody . length ; i ++ ) out [ i ] = resBody . charCodeAt ( i ) ;
287- res . postmanCollection = out ;
295+ res . postmanCollection = httpRes ?. data ;
288296 }
289297 break ;
290298 default :
291299 if ( utils . matchContentType ( contentType , `application/json` ) ) {
292- res . error = utils . objectToClass ( httpRes ?. data , shared . ErrorT ) ;
300+ res . error = utils . objectToClass ( JSON . parse ( decodedRes ) , shared . ErrorT ) ;
293301 }
294302 break ;
295303 }
@@ -328,6 +336,7 @@ export class ApiEndpoints {
328336 url : url ,
329337 method : "get" ,
330338 headers : headers ,
339+ responseType : "arraybuffer" ,
331340 ...config ,
332341 } ) ;
333342
@@ -343,21 +352,22 @@ export class ApiEndpoints {
343352 contentType : contentType ,
344353 rawResponse : httpRes ,
345354 } ) ;
355+ const decodedRes = new TextDecoder ( ) . decode ( httpRes ?. data ) ;
346356 switch ( true ) {
347357 case httpRes ?. status == 200 :
348358 if ( utils . matchContentType ( contentType , `application/json` ) ) {
349359 res . apiEndpoints = [ ] ;
350360 const resFieldDepth : number = utils . getResFieldDepth ( res ) ;
351361 res . apiEndpoints = utils . objectToClass (
352- httpRes ?. data ,
362+ JSON . parse ( decodedRes ) ,
353363 shared . ApiEndpoint ,
354364 resFieldDepth
355365 ) ;
356366 }
357367 break ;
358368 default :
359369 if ( utils . matchContentType ( contentType , `application/json` ) ) {
360- res . error = utils . objectToClass ( httpRes ?. data , shared . ErrorT ) ;
370+ res . error = utils . objectToClass ( JSON . parse ( decodedRes ) , shared . ErrorT ) ;
361371 }
362372 break ;
363373 }
@@ -400,6 +410,7 @@ export class ApiEndpoints {
400410 url : url ,
401411 method : "get" ,
402412 headers : headers ,
413+ responseType : "arraybuffer" ,
403414 ...config ,
404415 } ) ;
405416
@@ -415,21 +426,22 @@ export class ApiEndpoints {
415426 contentType : contentType ,
416427 rawResponse : httpRes ,
417428 } ) ;
429+ const decodedRes = new TextDecoder ( ) . decode ( httpRes ?. data ) ;
418430 switch ( true ) {
419431 case httpRes ?. status == 200 :
420432 if ( utils . matchContentType ( contentType , `application/json` ) ) {
421433 res . apiEndpoints = [ ] ;
422434 const resFieldDepth : number = utils . getResFieldDepth ( res ) ;
423435 res . apiEndpoints = utils . objectToClass (
424- httpRes ?. data ,
436+ JSON . parse ( decodedRes ) ,
425437 shared . ApiEndpoint ,
426438 resFieldDepth
427439 ) ;
428440 }
429441 break ;
430442 default :
431443 if ( utils . matchContentType ( contentType , `application/json` ) ) {
432- res . error = utils . objectToClass ( httpRes ?. data , shared . ErrorT ) ;
444+ res . error = utils . objectToClass ( JSON . parse ( decodedRes ) , shared . ErrorT ) ;
433445 }
434446 break ;
435447 }
@@ -472,6 +484,7 @@ export class ApiEndpoints {
472484 url : url ,
473485 method : "get" ,
474486 headers : headers ,
487+ responseType : "arraybuffer" ,
475488 ...config ,
476489 } ) ;
477490
@@ -486,15 +499,19 @@ export class ApiEndpoints {
486499 contentType : contentType ,
487500 rawResponse : httpRes ,
488501 } ) ;
502+ const decodedRes = new TextDecoder ( ) . decode ( httpRes ?. data ) ;
489503 switch ( true ) {
490504 case httpRes ?. status == 200 :
491505 if ( utils . matchContentType ( contentType , `application/json` ) ) {
492- res . apiEndpoint = utils . objectToClass ( httpRes ?. data , shared . ApiEndpoint ) ;
506+ res . apiEndpoint = utils . objectToClass (
507+ JSON . parse ( decodedRes ) ,
508+ shared . ApiEndpoint
509+ ) ;
493510 }
494511 break ;
495512 default :
496513 if ( utils . matchContentType ( contentType , `application/json` ) ) {
497- res . error = utils . objectToClass ( httpRes ?. data , shared . ErrorT ) ;
514+ res . error = utils . objectToClass ( JSON . parse ( decodedRes ) , shared . ErrorT ) ;
498515 }
499516 break ;
500517 }
@@ -552,6 +569,7 @@ export class ApiEndpoints {
552569 url : url ,
553570 method : "put" ,
554571 headers : headers ,
572+ responseType : "arraybuffer" ,
555573 data : reqBody ,
556574 ...config ,
557575 } ) ;
@@ -567,15 +585,19 @@ export class ApiEndpoints {
567585 contentType : contentType ,
568586 rawResponse : httpRes ,
569587 } ) ;
588+ const decodedRes = new TextDecoder ( ) . decode ( httpRes ?. data ) ;
570589 switch ( true ) {
571590 case httpRes ?. status == 200 :
572591 if ( utils . matchContentType ( contentType , `application/json` ) ) {
573- res . apiEndpoint = utils . objectToClass ( httpRes ?. data , shared . ApiEndpoint ) ;
592+ res . apiEndpoint = utils . objectToClass (
593+ JSON . parse ( decodedRes ) ,
594+ shared . ApiEndpoint
595+ ) ;
574596 }
575597 break ;
576598 default :
577599 if ( utils . matchContentType ( contentType , `application/json` ) ) {
578- res . error = utils . objectToClass ( httpRes ?. data , shared . ErrorT ) ;
600+ res . error = utils . objectToClass ( JSON . parse ( decodedRes ) , shared . ErrorT ) ;
579601 }
580602 break ;
581603 }
0 commit comments