现象:

项目中导入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. poj 3279 Fliptile (简单搜索)

    Fliptile Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 16558   Accepted: 6056 Descrip ...

  2. skyline加载arcgis发布的wms服务

    function AddWMSLayer(LayerName) {var _WMSUrl =“http://10.0.4.141:6080/arcgis/services/poss1/MapServe ...

  3. 使用git将本地java项目上传到GitHub

    使用git将项目上传到github(最简单方法) 声明:本人是根据上文给的链接的方式,上传到github上的,亲测有效. 首先你需要一个github账号,所有还没有的话先去注册吧! https://g ...

  4. CAS客户端与SpringSecurity集成

    4. CAS客户端与SpringSecurity集成 4.1 Spring Security测试工程搭建 (1)建立Maven项目casclient_demo3 ,引入spring依赖和spring ...

  5. CentOS7 下nginx与PHP的安装与配置

    下载Nginx 1.在服务器上新建文件夹  /home/soft/ ; 2.cd /home/soft/    =>    执行命令下载Nginx    wget http://nginx.or ...

  6. SQLServer配置镜像,无法将 ALTER DATABASE 命令发送到远程服务器实例,数据库镜像配置未更改。请确保该服务器已连接,然后重试。

    问题描述: 在做镜像的时候镜像已经连接成功,但是见证服务器却报错 然后tcping了端口啥都是通的,后面发现原来是主机名称一样导致的问题 发现host文件里面: C:\Windows\System32 ...

  7. IDEA 如何自动导入(import)

    如果大家正在使用一个未曾导入(import)过的类,或者它的静态方法或者静态字段,IDEA 会给出对应的建议,只要按下 ⌥(option)和回车就可以接受建议. 但我觉得这样做仍然很麻烦,不够智能化. ...

  8. Elasticsearch各版本的MSI安装包和Kibana各版本的zip包(Windows)

    elastic各产品下载列表页:https://www.elastic.co/cn/downloads/ 打开Elasticsearch的下载页后看到的是当前最新版本的安装界面,现在最新的版本是7.4 ...

  9. DevExpress Applications<3>

    Project Template Project Template Information Template Name Template Description Controls and Compon ...

  10. leaflet 结合 Echarts4 实现迁徙图(附源码下载)

    前言 leaflet 入门开发系列环境知识点了解: leaflet api文档介绍,详细介绍 leaflet 每个类的函数以及属性等等 leaflet 在线例子 leaflet 插件,leaflet ...