.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配置

.net core 使用swagger生成API文档

动作错误的swagger .net核心API模棱两可的HTTP方法

如何在 ASP.NET Core 中更改 Swagger 的基本 url