I am trying to create a generic web api in .net core 3.0. We have also implemented swagger in the same api project.
However, I am facing issue, as I am not able to see web api in swagger when I am trying to test/execute it locally. So, how to make swagger recognize this web api? Any specific setting we need to do it ?
Here is the api code.
[Route("api/[controller]/[action]")]
[ApiController]
public class GenericLookUpController : ControllerBase
{
[HttpPost]
public IActionResult GenericPostMethod<T>([FromBody] T record) where T : class
{
// some logic
}
}
When I write non generic web api, it's visible in swagger. I have also made the controller class as generic, but it doesn't resolved the issue.
Basically, I don't want entire controller as generic controller but just few web api's for lookup tables. These generic web api's will be used for CRUD operation for lookup tables.
So, what changes I need to make so web api will be visible in swagger?
Any help on this appreciated !