.Net WabApi Swagger Failed to load API definition
Posted シ゛甜虾
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了.Net WabApi Swagger Failed to load API definition相关的知识,希望对你有一定的参考价值。
swagger出现Failed to load API definition.原代码
[ApiController]
[Route("[controller]")]
public class EdgeController : ControllerBase
{
[HttpPost("SetSetting")]
public SettingResultDto SetSetting(SettingDto settingDto)
{
var deviceService = SingleService.Services.GetService<IDeviceService>();
return deviceService.Setting(settingDto);
}
[HttpPost("SetWorkmode")]
public SetWorkmodeResultDto SetWorkmode(SetWorkmodeDto setWorkmodeDto)
{
var deviceService = SingleService.Services.GetService<IDeviceService>();
return deviceService.SetWorkmode(setWorkmodeDto);
}
}
修改后的代码,显性的加上地址 [HttpPost("SetSetting")]
[ApiController]
[Route("[controller]")]
public class EdgeController : ControllerBase
{
[HttpPost("SetSetting")]
public SettingResultDto SetSetting(SettingDto settingDto)
{
var deviceService = SingleService.Services.GetService<IDeviceService>();
return deviceService.Setting(settingDto);
}
[HttpPost("SetWorkmode")]
public SetWorkmodeResultDto SetWorkmode(SetWorkmodeDto setWorkmodeDto)
{
var deviceService = SingleService.Services.GetService<IDeviceService>();
return deviceService.SetWorkmode(setWorkmodeDto);
}
}
以上是关于.Net WabApi Swagger Failed to load API definition的主要内容,如果未能解决你的问题,请参考以下文章
.Net Core Web API Swagger 没有找到该网址的网页:http://localhost/swagger
.NET Core基础篇之:集成Swagger文档与自定义Swagger UI
ASP .NET Core从零到壹 || Swagger配置