Great job on the Web Api plugin. I am currently creating a Next.js site using the web API, but I ran into an issue today. When calling the List action in NewsController, there is an error thrown. I tried calling the endpoint from my frontend, but I also tried using the Try it out button in the Swagger doc to make sure I wasnt doing something weird.
The error produced:
`Cannot create an instance of abstract type Nop.Web.Framework.UI.Paging.BasePageableModel. (Parameter 'type')
It is very puzzling to me as from what I see, NewsPagingFilteringModel only inherits from
the abstract class BasePageableModel, so it definitely should be able to be instantiated.
I looked in the code and I found this:
public virtual async Task<IActionResult> List([FromBody] BasePageableModelDto command)
{
if (!_newsSettings.Enabled)
return BadRequest($"The setting {nameof(_newsSettings.Enabled)} is not enabled");
var model = await _newsModelFactory.PrepareNewsItemListModelAsync(command.FromDto<NewsPagingFilteringModel>());
return Ok(model.ToDto<NewsItemListModelDto>());
}
It seems there wasnt a dto mapping beteween BasePageableDto and NewsPagingFilteringModel, so I added one in the WebApiFrontendMapperConfiguration, but the problem was still there.
So, I went ahead and replaced:
public virtual async Task<IActionResult> List([FromBody] BasePageableModelDto command)
To my own model (which I also added a mapping for):
public virtual async Task<IActionResult> List([FromBody] NewsPagingFilteringModelDto command)
But still, the same error is thrown.
Any ideas?