I defined a class named BaseController
which implements from ControllerBase
, it has a query function with [HttpGet]
, when i define another class named UniqueController
implements from BaseController
, and then overwrite the query function, got error:
Actions require an explicit HttpMethod binding for Swagger/OpenAPI 3.0
// basecontroller
public class BaseController<T> : ControllerBase where T : BaseModel, new()
{
[HttpGet]
public virtual async Task<IActionResult> Query()
{
var models = await _baseService.QueryModelAsync();
return Ok(ApiResultHelper.Success("Success", new { Value = models }, models.Count));
}
}
// uniquecontroller
public class UniqueController<T> : BaseController<T> where T : UniqueModel, new()
{
public new async Task<IActionResult> Query()
{
var models = await _modelService.QueryModelAsync();
return Ok(ApiResultHelper.Success("Success", new { Value = models }, models.Count));
}
}
// module controller use
public class UserController : UniqueController<UserModel>
{
public UserController(UniqueService<UserModel> modelService, IHttpContextAccessor httpContextAccessor)
: base(modelService, httpContextAccessor) {}
}