I am investigating the refit library and evaluating if I is worth integrating in my project.
Let's say I have this Controller that accepts a POST
message with a specific contract:
[Route("api/[controller]")]
[ApiController]
public class KeepAliveController : ControllerBase
{
[HttpPost]
public IActionResult Post(KeepAliveContract keepAliveContract)
{
//
}
}
From what I understand from the refit
documentation, I have to create an interface. Let's call it IKeepAliveService
. It would look like this:
public interface IKeepAliveService
{
[Post("api/keepalive")]
Task SendKeepAliveAsync(KeepAliveContract keepAliveContract);
}
This way of doing things lead to potential runtime errors, if I mess up the route in the PostAttribute
or in the signature itself.
Question
Is there a way to automatically generate this interface out of the existing controllers and, as such reduce the risk of bugs?