Ambiguous HTTP method Actions require an explicit HttpMethod binding for Swagger 2.0 异常
网上看了很多关于此异常的解决方案,但是大多数都是不能用的,今天把正确的解决方案记录下来,以帮助需要的人
问题:有些接口没有设置HttpPost或HttpGet,非接口设置访问权限为private,控制台可以看到报错位置为UserController.Info

接口错误示例:
public object Get()
{
MongoDbContext dbContext = new MongoDbContext();
return new {
API = true,
Database = dbContext.Status()
};
}
接口正确示例:
[HttpGet]
public object Get()
{
MongoDbContext dbContext = new MongoDbContext();
return new {
API = true,
Database = dbContext.Status()
};
}
非接口(方法)示例:(访问权限设置成private,protected)
private DateTime SecondsToDateTime(long seconds)
{
var d1970 = new DateTime(, , );
DateTime now = new DateTime(d1970.Ticks + seconds * );
///零时区
return TimeZoneInfo.ConvertTimeFromUtc(now, TimeZoneInfo.Local);
}
参考
https://stackoverflow.com/questions/47822177/swagger-net-core-api-ambiguous-http-action-debugging
Ambiguous HTTP method Actions require an explicit HttpMethod binding for Swagger 2.0 异常的更多相关文章
- Ambiguous HTTP method Actions require an explicit HttpMethod binding for Swagger 2.0
异常内容 NotSupportedException: Ambiguous HTTP method for action . Actions require an explicit HttpMetho ...
- .Net Core Swagger:Actions require an explicit HttpMethod binding for Swagger 2.0
添加完Swagger包引用后运行报错:Actions require an explicit HttpMethod binding for Swagger 2.0 第一时间想到了父类控制器 没有添加 ...
- .Netcore Swagger - 解决外部库导致的“Actions require an explicit HttpMethod binding for Swagger 2.0”
现象: 项目中导入Ocelot后,swagger页面无法正常显示,查看异常发现 Ocelot.Raft.RaftController 中的 Action 配置不完全,swagger扫描时不能正确生成 ...
- Actions require unique method/path combination for Swagger
原文:Actions require unique method/path combination for Swagger services.AddSwaggerGen (c => { c.Re ...
- 使用ControllerAdvice注意事项,Ambiguous @ExceptionHandler method mapped for [class org.springframework.web.bind.MethodArgumentNotValidException]
前言 ControllerAdvice非常好用,可以把系统内部的异常统一处理.用起来也很简单.比如,http://www.cnblogs.com/woshimrf/p/spring-web-400.h ...
- 解决Redisson出现Failed to instantiate [org.redisson.api.RedissonClient]: Factory method 'create' threw exception; nested exception is java.lang.ArrayIndexOutOfBoundsException: 0的问题
一.背景 最近项目中使用了redisson的哨兵模式来作为redis操作的客户端,然后一个意外出现了,启动报:Failed to instantiate [org.redisson.api.Redis ...
- 【netcore入门】在Windows IIS上部署.NET Core 2.1项目
部署之前先检查下面2个先决条件是否满足 1.安装了 IIS 模块 win7 在 控制面板→程序和功能→打开或关闭Windows功能→勾选Internet 信息服务(Internet Informati ...
- Swagger使用的时候报错:Failed to load API definition
NuGet添加Swashbuckle.AspNetCore,在Startup.cs添加和启用中间件Swagger public void ConfigureServices(IServiceColle ...
- 武装你的WEBAPI-OData常见问题
本文属于OData系列 目录 武装你的WEBAPI-OData入门 武装你的WEBAPI-OData便捷查询 武装你的WEBAPI-OData分页查询 武装你的WEBAPI-OData资源更新Delt ...
随机推荐
- 032-PHP中关于数组排序的usort()函数
<?php function re($a, $b) { return ($a < $b) ? 1 : -1; } $x = array(1, 3, 2, 5, 9); usort($x, ...
- 第一个flink application
导入maven依赖 需要注意的是,如果使用scala写程序,导入的依赖跟java是不一样的 Maven Dependencies You can add the following dependenc ...
- CSU 1126 DFS前缀和
在一棵树上找影响最小的某个点,某个点的影响是等于其他点到他的距离*其他点的权值 的和 我一开始也找不到什么好的方法,只能想到每个点暴力去判断,但是这样肯定会超时(10^5个点),又有点想用类似前缀和, ...
- 十三、react-router 4.x的基本配置
路由的定义及作用 根组件根据客户端不同的请求网址显示时,要卸载上一个组件,再挂载下一个组件,如果手动操作话将是一个巨大麻烦.具体过程如下图: [根组件] ↑ [首页组件] [新闻组件] [商品组件] ...
- wget 403 forbidden
CMD: wget --user-agent="Mozilla" down_url wget -U Mozilla 下载地址 wget -U NoSuchBrowser/1.0 下 ...
- oracle中设置主键
1.创建表 .创建表 create table "c_user"( "id" number primary key, "username" ...
- 18 —— node 热部署工具 — supervisor /nodemon 。
1,全局安装: npm install -g supervisor 2,使用: —————————————————————————————— nodemon 和 supervisor 流程一致.
- tableau中图形分析相关设置
1.柱形堆叠图单元格顶部显示总计值(可通过参考线实现) 2.调节图形单元格的宽窄度 (ctrl + 右键/左键) 3.折线图预测区间 趋势区间线 分析中预测并不是针对所有的日期格式均其作用,比如日期格 ...
- 手把手教你用Python实现“坦克大战”,附详细代码!
小时候玩的“坦克大战”,你还记得吗? 满满的回忆 ! 今天,我们使用Python以及强大的第三方库来实现一个简单的坦克大战游戏. 整体效果 环境依赖 python3.7 pygame1.9.6 ...
- comparable接口 和 comparator接口的特点与区别
1. Comparator 和 Comparable 相同的地方 他们都是java的一个接口, 并且是用来对自定义的class比较大小的. 什么是自定义class: 如 public class Pe ...