如何在angular中为二进制下载指定OpenAPI

如何在angular中为二进制下载指定OpenAPI,angular,swagger-codegen,Angular,Swagger Codegen,我有一个下载二进制文件的方法。openapi.yaml中当前有以下规范: /processing/getZippedReports: post: tags: - ProcessingRest description: Get the reports operationId: getZippedReports requestBody: description: The list of items for whi

我有一个下载二进制文件的方法。openapi.yaml中当前有以下规范:

  /processing/getZippedReports:
    post:
      tags:
      - ProcessingRest
      description: Get the reports
      operationId: getZippedReports
      requestBody:
        description: The list of items for which to get the HTML
        content:
          application/json:
            schema:
              type: array
              items:
                type: string
        required: true
      responses:
        200:
          description: file with zipped reports
          content:
            application/octet-stream: {}
生成的typescript代码包含对httpClient的调用:

return this.httpClient.post<any>(`${this.configuration.basePath}/processing/getZippedReports`,
    requestBody,
    {
        withCredentials: this.configuration.withCredentials,
        headers: headers,
        observe: observe,
        reportProgress: reportProgress
    }
);

这是Swagger codegen中的错误/缺失功能,还是我应该更改openapi定义以获得工作角度代码?

若要指示响应是二进制文件,请使用带有
type:string
format:binary
的模式

内容:
应用程序/八位字节流:
模式:
类型:字符串
格式:二进制

似乎有一个
x-is-file
供应商扩展名,我在源代码中找到了它,但没有关于它的文档。这将导致controllerService.ts中正确的
responseType
定义

        "responses": {
            "default": {
                "x-is-file": true,
                "description": "default response",
                "content": {
                    "application/octet-stream": {
                        "schema": {
                            "type": "file"
                        }
                    }
                }
            }
        },

尝试将空响应模式
{}
替换为
类型:string
+
格式:binary
的模式。这有帮助吗?是的,这确实改变了HttpClient post请求的签名。请作为答案张贴,这样我就可以接受我的问题与原来的海报相同。我尝试过@Helen,因为它被标记为已接受的答案,但仍然没有在生成的代码中包含
responseType:'blob'
。有什么帮助吗?
        "responses": {
            "default": {
                "x-is-file": true,
                "description": "default response",
                "content": {
                    "application/octet-stream": {
                        "schema": {
                            "type": "file"
                        }
                    }
                }
            }
        },