swagger出现Failed to load API definition.原代码
[ApiController]
[Route("[controller]")]
public class EdgeController : ControllerBase
{
public SettingResultDto SetSetting(SettingDto settingDto)
{
var deviceService = SingleService.Services.GetService<IDeviceService>();
return deviceService.Setting(settingDto);
}
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);
}
}