我开发了一个ASP.NET Core 3.1应用程序,并包含Swagger。一切工作都很好,直到我引入了一种方法,而未明确定义HTTP操作,但具有如下所示的route操作,如我的requestscontroller
[Authorize]
[Produces("application/json")]
[ApiExplorerSettings(IgnoreApi = true)]
public class RequestsController : Controller
{
private readonly DataSubjectRequestWebServContext _context;
private readonly IRequestManager _manager;
public RequestsController(DataSubjectRequestWebServContext context, IRequestManager manager)
{
_context = context;
_manager = manager;
}
// Get Homepage
public IActionResult Index()
{
return View();
}
// Get Privacy Policy
[Route("Privacy")]
public IActionResult Privacy()
{
return View();
}
使用此方法启动应用程序时,出现以下消息:
无法加载API定义。
然后,我在控制器中加入了[ApiExplorerSettings(IgnoreApi = true)]
。
再次运行它可以工作,但是我得到“规范中未定义任何操作!”错误消息