I have an AppointmentController with a Route attribute and an HTTPGet method inside of it
[ApiController, Authorize]
[Route("api/[controller]")]
public class AppointmentController : ControllerBase
{
[HttpGet("/user/{userId:guid}")]
public async Task<ActionResult<ApiResponse<IEnumerable<Appointment>>>> GetUserAppointments([FromRoute] Guid userId) {}
}
I want the route to be : "/api/appointment/user/:userId"
Instead I get "/user/:userId" in the Swagger UI
What is the problem here?
>Solution :
Just remove the forward slash / before your route "user/{userId:guid}"
[ApiController, Authorize]
[Route("api/[controller]")]
public class AppointmentController : ControllerBase
{
[HttpGet("user/{userId:guid}")]
public async Task<ActionResult<ApiResponse<IEnumerable<Appointment>>>> GetUserAppointments([FromRoute] Guid userId) {}
}