I try to have multiple routes with equal URLs like files/{fileId} but different return values. I would like to distinguish the routes based on the MIME type. In one case I want the file details in JSON format and in the other the file itself.
/// <summary>
/// get a file by its Id
/// </summary>
/// <response code="200">The file for download</response>
/// <response code="404">File id was not found</response>
[HttpGet("files/{fileId}")]
public async Task<IActionResult> GetFile([FromRoute] int fileId)
{
var fileModel = await _boFileService.GetFileStreamAndFileName(fileId);
return File(fileModel.Stream, MediaTypeNames.Application.Octet, fileModel.FileName);
}
/// <summary>
/// get the details of a file by its Id
/// </summary>
/// <response code="200">The details for the file, like name, status and type</response>
/// <response code="404">File id was not found</response>
[HttpGet("files/{fileId}")]
public async Task<ActionResult<BoFileModel>> GetFileDetails([FromRoute] int fileId)
{
return await _boFileService.GetFileDetails(fileId);
}
At the moment I got the following error:
Actions require a unique method/path combination for Swagger/OpenAPI 3.0
Has anybody an idea? Is it possible to have equal routes?
Thank you