现象:

项目中导入Ocelot后,swagger页面无法正常显示,查看异常发现 Ocelot.Raft.RaftController 中的 Action 配置不完全,swagger扫描时不能正确生成 swagger.json

解决方法:

在扫描中隐藏Ocelot的controller,避免被swagger生成文档

创建ApiExplorerIgnores

    public class ApiExplorerIgnores : IActionModelConvention
{
/// <summary>
/// Ocelot自带的Controller与swagger2.0冲突,在此排除扫描
/// </summary>
/// <param name="action"></param>
public void Apply(ActionModel action)
{
//冲突的Ocelot.Raft.RaftController
if (action.Controller.ControllerName.Equals("Raft"))
action.ApiExplorer.IsVisible = false;
//Ocelot.Cache.OutputCacheController
if (action.Controller.ControllerName.Equals("OutputCache"))
action.ApiExplorer.IsVisible = false;
}
}

setup.cs中添加

services.AddMvc(c => c.Conventions.Add(new ApiExplorerIgnores()));

.Netcore Swagger - 解决外部库导致的“Actions require an explicit HttpMethod binding for Swagger 2.0”的更多相关文章

  1. Ambiguous HTTP method Actions require an explicit HttpMethod binding for Swagger 2.0

    异常内容 NotSupportedException: Ambiguous HTTP method for action . Actions require an explicit HttpMetho ...

  2. .Net Core Swagger:Actions require an explicit HttpMethod binding for Swagger 2.0

    添加完Swagger包引用后运行报错:Actions require an explicit HttpMethod binding for Swagger 2.0 第一时间想到了父类控制器 没有添加 ...

  3. Ambiguous HTTP method Actions require an explicit HttpMethod binding for Swagger 2.0 异常

    网上看了很多关于此异常的解决方案,但是大多数都是不能用的,今天把正确的解决方案记录下来,以帮助需要的人 问题:有些接口没有设置HttpPost或HttpGet,非接口设置访问权限为private,控制 ...

  4. Actions require unique method/path combination for Swagger

    原文:Actions require unique method/path combination for Swagger services.AddSwaggerGen (c => { c.Re ...

  5. [Cocos2d-x]解决Android平台ndk-build时不自动删除外部库

    参考链接: http://blog.chinaunix.net/uid-26009923-id-3430612.html http://hi.baidu.com/hpyfei/item/52a2b21 ...

  6. ios开发中用过的一些外部库总结 cocoapods list

    下面几个库是在之前的一个ios app开发中使用过的一些外部库: 1. zbar :2. shakebox :3. processbar :4. tableviewcontroller :新版的sta ...

  7. linux下编译ffmpeg 引入外部库x264

    Found no assembler Minimum version is nasm-2.13 If you really want to compile without asm, configure ...

  8. GNU编译器学习 --> 如何链接外部库【Linking with external libraries】

    库也就是我们常说的library,一个库是若干个已经编译过的目标文件(.obj)的集合,它可以被链接到程序里.那么我们最常见的使用就是,我们在编程时会调用一些函数,这些函数别人已经写好了,它就放在库里 ...

  9. [转帖]Redis持久化--Redis宕机或者出现意外删库导致数据丢失--解决方案

    Redis持久化--Redis宕机或者出现意外删库导致数据丢失--解决方案 https://www.cnblogs.com/xlecho/p/11834011.html echo编辑整理,欢迎转载,转 ...

随机推荐

  1. 图片验证码推导逻辑,Image.new,ImageDraw, ImageFont.truetype的用法

    #一, 创建图片并在图上添加文本 from PIL import Image,ImageDraw,ImageFont a = '我们不一样' # 定义文本 font = ImageFont.truet ...

  2. QQ音乐接口api,包括付费音乐、无损音乐、高品质音乐地址解析接口api

    QQ音乐网站所有音乐(包括付费.无损等版权音乐解析接口地址url). mp3 普通高品 http://dl.stream.qqmusic.qq.com/M5000012gqVh4fFvVK.mp3?v ...

  3. logging in kubernetes

    background docker docker的日志输出可以通过指定driver输出到不同的位置,常用的是journald和json-file. 使用journald日志输出可能受限于jourand ...

  4. 《.Net 最佳实践》 - 学习笔记

    <.Net 最佳实践> ========== ========== ==========[作者] (美) Stephen Ritchie[译者] (中) 黄灯桥 黄浩宇 李永[出版] 机械 ...

  5. kvm磁盘管理

    kvm磁盘管理 kvm虚拟机虚拟磁盘格式转换 各种格式说明介绍 row:裸格式,占用空间较大,不支持快照功能,性能较好,不方便传输(顺序读写) 50G 2G 传输50G qcow2:cow 占用空间小 ...

  6. linux 文件管理命令

    一,文件查看more,less,head,tail,cat,tac 分屏查看文件内容 more:和man用法一样,但翻屏到尾部自动推出. less:和man用法一样. head:查看文件的前n行.n默 ...

  7. IT兄弟连 HTML5教程 CSS3属性特效 定义省略文本的处理方式

    text-overflow属性仅是注解,当文本溢出时是否显示省略标记,并不具备其它的样式属性定义.我们想要实现溢出时产生省略号的效果.还必须定义:强制文本在一行内显示(white-space:nowr ...

  8. spinand之data buffer

    data buffer简介 spinand一般会有一个内置的data buffer. 以W25N01GV为例,一个page是2048bytes外加64bytes的spare数据,其data buffe ...

  9. Spring Cloud系列:不重启eureka,清除down掉的服务

    场景描述 做项目的时候,我的服务改了个ip,然后重新启动后,原ip的服务down掉了,但是没有清楚掉,还在上面,导致我用swagger测试的时候,访问不到真正up的程序.重启eureka又不划算,于是 ...

  10. Selenium(九):Xpath选择器

    1. Xpath选择器 1.1 Xpath语法简介 前面我们学习了CSS选择元素. 大家可以发现非常灵活.强大. 还有一种灵活.强大的选择元素的方式,就是使用Xpath表达式. XPath (XML ...