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
You should be able to use the ConsumesAttribute to describe what content types maps to which controller action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With