I have an issue which seems common from what I've researched around my controller names conflicting and issues with swagger.
If I have two Get()
functions in Controller one
and two Get()
functions in Controller two I receive the error:
Conflicting method/path combination "GET {id}" for actions
Important to note:
ODataController
like below:public class OrdersController : ODataController
public class OrdersController : BaseApiController
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.OData.Routing.Controllers;
namespace API.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class BaseApiController : ODataController
{
}
}
The main problem I have now is Swagger displaying two sets of endpoints:
one for all my /api/<controller>
endpoints as well as /odata/<controller>
(duplicated) and I only want the odata ones, but if I remove the Route the error will reoccur.
one for all my /api/ endpoints as well as /odata/ (duplicated) and I only want the odata ones. But if I remove the Route the error will reoccur
Remove both[ApiController]
and [Route("api/[controller]")]
Here's an example of OData Controller in this document