I have a controller say 'SampleController' that uses 'MyControllerBase'(from a NuGet package) as a base class.
I am trying to add API documentation using swagger but the swagger is unable to fetch 'SampleController' thus cannot create swagger.json.
I am getting the error "fetch error: /swagger/v1/swagger.json"
'MyControllerBase' inherits 'ControllerBase' so 'SampleController' is working as an API should work.
How can I tell swagger to use 'MyControllerBase' to find Controllers
From Nuget Package:
namespace My.ApiFormatter.Controller
{
public abstract class MyControllerBase<T> : ControllerBase, IFilterableController
{
public virtual Dictionary<string, IFilterMapper> FilterWhitelist => new Dictionary<string, IFilterMapper>();
}
}
Implementation:
[Route("api/[controller]")]
[ApiController]
public class SampleController : MyControllerBase<ExampleData>
{
[HttpGet]
public override ActionResult<CollectionEnvelope<ExampleData>> GetAll()
{
var results = ExampleDatas
.Where(x => x.Key > (Info.PageSize * Info.SkipPages)
&& x.Key <= (Info.PageSize * (Info.SkipPages + 1)))
.Select(y => y.Value).ToList();
var collectionEnvelope = GetCollectionEnvelope(results, ExampleDatas.Count);
return Ok(collectionEnvelope);
}
}