我有一个具有属性的控制器(asp.net核心):
[ProducesResponseType(typeof(FileContentResult), 200)]
并返回一个:
return File(myFileStream, "application/pdf", myFileName);
然后 生成 这样大张旗鼓:
型号:
export interface FileContentResult {
fileContents?: string;
contentType?: string;
fileDownloadName?: string;
lastModified?: string;
entityTag?: EntityTagHeaderValue;
}
服务:
MyAPIPost(someData: string): Observable<HttpResponse<FileContentResult>> {
let __params = this.newParams();
let __headers = new HttpHeaders();
let __body: any = null;
__body = someData;
let req = new HttpRequest<any>(
'POST',
this.rootUrl + `_api_url_`,
__body,
{
headers: __headers,
params: __params,
responseType: 'json'
});
return this.http.request<any>(req).pipe(
filter(_r => _r instanceof HttpResponse),
map(_r => {
let _resp = _r as HttpResponse<any>;
let _body: FileContentResult = null;
_body = _resp.body as FileContentResult;
return _resp.clone({body: _body}) as HttpResponse<FileContentResult>;
})
);
}
由于无法解析为json,因此会产生错误。我可以手动将响应类型更改为Blob,然后保存pdf文件,但是我无法访问该文件名。 在此实现中我做错了什么?
我缺少的swagger代码生成有任何配置吗? (下载在Swagger UI上运行正常)