@@ -374,19 +374,33 @@ export class ContentApiResponseProcessor {
374374 * @params response Response returned by the server for a request to download
375375 * @throws ApiException if the response code was not in [200, 299]
376376 */
377- public async downloadWithHttpInfo ( response : ResponseContext ) : Promise < HttpInfo < void > > {
377+ public async downloadWithHttpInfo ( response : ResponseContext ) : Promise < HttpInfo < HttpFile > > {
378378 const contentType = ObjectSerializer . normalizeMediaType ( response . headers [ "content-type" ] ) ;
379+ if ( isCodeInRange ( "200" , response . httpStatusCode ) ) {
380+ const body : HttpFile = await response . getBodyAsFile ( ) as any as HttpFile ;
381+ return new HttpInfo ( response . httpStatusCode , response . headers , response . body , body ) ;
382+ }
383+ if ( isCodeInRange ( "403" , response . httpStatusCode ) ) {
384+ throw new ApiException < undefined > ( response . httpStatusCode , "Insufficient permissions to access the file" , undefined , response . headers ) ;
385+ }
386+ if ( isCodeInRange ( "404" , response . httpStatusCode ) ) {
387+ throw new ApiException < undefined > ( response . httpStatusCode , "File not found at the specified path" , undefined , response . headers ) ;
388+ }
379389 if ( isCodeInRange ( "0" , response . httpStatusCode ) ) {
380390 const body : Error = ObjectSerializer . deserialize (
381391 ObjectSerializer . parse ( await response . body . text ( ) , contentType ) ,
382- "Error" , ""
392+ "Error" , "binary "
383393 ) as Error ;
384394 throw new ApiException < Error > ( response . httpStatusCode , "An error occurred." , body , response . headers ) ;
385395 }
386396
387397 // Work around for missing responses in specification, e.g. for petstore.yaml
388398 if ( response . httpStatusCode >= 200 && response . httpStatusCode <= 299 ) {
389- return new HttpInfo ( response . httpStatusCode , response . headers , response . body , undefined ) ;
399+ const body : HttpFile = ObjectSerializer . deserialize (
400+ ObjectSerializer . parse ( await response . body . text ( ) , contentType ) ,
401+ "HttpFile" , "binary"
402+ ) as HttpFile ;
403+ return new HttpInfo ( response . httpStatusCode , response . headers , response . body , body ) ;
390404 }
391405
392406 throw new ApiException < string | Buffer | undefined > ( response . httpStatusCode , "Unknown API Status Code!" , await response . getBodyAsAny ( ) , response . headers ) ;
0 commit comments