У меня есть метод для загрузки бинарного файла.В настоящее время в 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: {}
Сгенерированный машинописный код содержит этот вызов httpClient:
return this.httpClient.post<any>(`${this.configuration.basePath}/processing/getZippedReports`,
requestBody,
{
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
Таким образом, angular, кажется, не может получитьбинарный контент.Мне пришлось изменить httpClient, использовать сигнатуру без переменной типа post
и добавить responseType: blob
к параметрам
return this.httpClient.post(`${this.configuration.basePath}/processing/getZippedReports`,
requestBody,
{
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: 'response',
responseType: 'blob',
reportProgress: reportProgress
}
);
Является ли это ошибкой / отсутствующей функцией в коде Swagger или мне следует изменитьопределение openapi, чтобы получить рабочий угловой код?