【发布时间】:2018-03-07 19:07:31
【问题描述】:
我正在使用 Swagger for dotnet core 记录我的 dotnet 核心 Web API。
我已阅读文档告诉我需要添加
[ProducesResponseType(typeof(XXXXX),200)]上面的控制器方法,帮助swagger判断方法的响应类型。
我有一个返回文件的控制器方法,我正在尝试弄清楚如何告诉 swagger 我正在返回一个文件。
public class DocumentController : Controller
{
private readonly IDocumentService _documentService;
public DocumentController(IDocumentService documentService)
{
_documentService = documentService;
}
[HttpGet("{documentId}", Name= DocumentRoutes.Document)]
[ProducesResponseType(typeof(XXXXX), 200)] // <== What goes here?
public async Task<IActionResult> GetDocument(Guid documentId)
{
DocumentAdto documentAdto = await _documentService.GetAsync(documentId);
return File(documentAdto.DocumentBytes, documentAdto.ContentType, documentAdto.Name);
}
}
有人有什么想法吗?
我考虑过 byte[] 但这只是说返回类型是“byte”。
【问题讨论】:
标签: c# .net-core swagger asp.net-core-webapi