i define a class named basecontroller implement from controllerbase, it has a query function with [httpget], when i define another class named uniquecontroller implement 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)
{
}
}
#exception
An unhandled exception has occurred while executing the request.
Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorException: Ambiguous HTTP method for action - QfWebServer.Client.Controllers.Framework.RoleController.Query (QfWebServer.Client). Actions require an explicit HttpMethod binding for Swagger/OpenAPI 3.0
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwaggerDocumentWithoutFilters(String documentName, String host, String basePath)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwaggerAsync(String documentName, String host, String basePath)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
New contributor
ltdwonder223 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.