swagger-angular-generator icon indicating copy to clipboard operation
swagger-angular-generator copied to clipboard

Blob responsetype error

Open KnutHaraldR opened this issue 5 years ago • 1 comments

I have a method that expects type blob. Intead what's generated is this

exportvalues(params: ExportvaluesParams): Observable<blob> {
    const pathParams = {
      id: params.id,
    };
    return this.http.get<blob>(`/api/dimensions/${pathParams.id}/exportvalues`);
  }

Which gives the error that blob don't exist.

Here is an example correct implementation:

GetExportValuesResponse(id: number): __Observable<__StrictHttpResponse<any>> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;

    let req = new HttpRequest<any>(
      'GET',
      this.rootUrl + `/api/dimensions/${id}/exportvalues`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'blob'
      });

    return this.http.request<any>(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
        return _r as __StrictHttpResponse<any>;
      })
    );
  }

TL;DR: Use <any> and responseType: 'blob'

KnutHaraldR avatar May 31 '19 08:05 KnutHaraldR

Note: I've found that "blob" is not part of the Swagger spec. However, "file" accomplishes the same thing.

KnutHaraldR avatar Jun 01 '19 11:06 KnutHaraldR