The specific error is:
SwaggerGeneratorException: Conflicting method/path combination "GET Exercise" for actions - FitnessTracker.Controllers.ExerciseController.GetExerciseList (FitnessTracker),FitnessTracker.Controllers.ExerciseController.GetExerciseById (FitnessTracker). Actions require a unique method/path combination for Swagger/OpenAPI 3.0. Use ConflictingActionsResolver as a workaround
I thought web api inferred the verb from the function prefix, ie. Get
or Post
and then as long as the function name was unique or even the parameter list was unique that was sufficient.
Here's my controller:
[ApiController]
[Route("[controller]")]
public class ExerciseController : ControllerBase
{
private readonly IDL DL;
private readonly ILogger<ExerciseController> logger;
public ExerciseController(IDL dL, ILogger<ExerciseController> logger)
{
DL = dL;
this.logger = logger;
}
[HttpGet(Name = "GetExerciseList")]
[Route("api/[controller]/[action]")]
public List<Exercise> GetExerciseList()
{
return DL.GetExerciseList();
}
[HttpGet(Name = "GetExerciseById")]
[Route("api/[controller]/[action]")]
public Exercise GetExerciseById(string exerciseId)
{
return DL.GetExerciseById(exerciseId);
}
}
I'm also not really clear on the purpose of Name = "GetExerciseList"
in the attribute, seems redundant.
So how is it getting confused? The functions are distinct in both name and parameter list.
I've tried various Route attributes, none of which resolve the issue, including:
[Route("api/[controller]/[action]")]
[Route("api/[Controller]/ExerciseList")]
[Route("api/Exercise/ExerciseList")]
[Route("RoutingSucks")]
[Route("ICanPutAnythingHereAndItMakesNoDifference")]