swagger error: Conflicting schemaIds: Duplicate schemaIds detected for types A and B
使用Web API并使用swashbuckle生成swagger文档,我在两个不同的命名空间中定义了两个具有相同名称的不同类。当我在浏览器中打开swagger页面时,它说:
Conflicting schemaIds: Duplicate schemaIds detected for types A and B. See the config setting - "UseFullTypeNameInSchemaIds" for a potential workaround
完整消息:
{
"message": "An error has occurred.",
"exceptionMessage": "Conflicting schemaIds: Duplicate schemaIds detected for types Amo.Common.AjaxResult`1[[System.Collections.Generic.List`1[[Amo.UsdtCoin.UsMerchantClient+oListTransactionResult, Amo.UsdtCoin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] and Amo.Common.AjaxResult`1[[System.Collections.Generic.List`1[[Amo.BtcCoin.MerchantClient+oListTransactionResult, Amo.BitCoin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]. See the config setting - \"UseFullTypeNameInSchemaIds\" for a potential workaround",
"exceptionType": "System.InvalidOperationException",
"stackTrace": " 在 Swashbuckle.Swagger.SchemaRegistry.CreateRefSchema(Type type)\r\n
在 Swashbuckle.Swagger.SchemaRegistry.CreateInlineSchema(Type type)\r\n
在 Swashbuckle.Swagger.SchemaRegistry.GetOrRegister(Type type)\r\n
在 Swashbuckle.Swagger.SwaggerGenerator.CreateOperation(ApiDescription apiDesc, SchemaRegistry schemaRegistry)\r\n
在 Swashbuckle.Swagger.SwaggerGenerator.CreatePathItem(IEnumerable` apiDescriptions, SchemaRegistry schemaRegistry)\r\n
在 Swashbuckle.Swagger.SwaggerGenerator.<>c__DisplayClass7.<GetSwagger>b__4(IGrouping` group)\r\n
在 System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable` source, Func` keySelector, Func` elementSelector, IEqualityComparer` comparer)\r\n
在 Swashbuckle.Swagger.SwaggerGenerator.GetSwagger(String rootUrl, String apiVersion)\r\n
在 Amo.Client.CachingSwaggerProvider.GetSwagger(String rootUrl, String apiVersion) 位置 E:\\codes\\USDTSolution\\Amo.Client\\App_Start\\SwaggerConfig.cs:行号 \r\n
在 Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n
在 System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n
在 System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n
在 System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n 在 System.Web.Http.HttpServer.<SendAsync>d__24.MoveNext()"
}
我不想改变类的名字。我该如何解决?
解决方法1:
services.ConfigureSwaggerGen(options =>
{
//your custom configuration goes here ... // UseFullTypeNameInSchemaIds replacement for .NET Core
options.CustomSchemaIds(x => x.FullName);
});
解决方法2:
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
// your configs... c.SchemaId(x => x.FullName); // other configs...
})
.EnableSwaggerUi(c =>
// ....
});
解决方法3:
c.UseFullTypeNameInSchemaIds();
swagger error: Conflicting schemaIds: Duplicate schemaIds detected for types A and B的更多相关文章
- vue报错之Duplicate keys detected: '0'. This may cause an update error.
昨天运行vue项目的时候,出现了[Vue warn]: Duplicate keys detected: '0'. This may cause an update error(错误,检测到重复的ke ...
- [Vue warn]: Duplicate keys detected: '0'. This may cause an update error.
1.[Vue warn]: Duplicate keys detected: '0'. This may cause an update error. 第一眼看到这个错误一脸懵逼,项目使用很久了,代码 ...
- Duplicate keys detected: '0'. This may cause an update error.
在运行vue项目的时候报了:[Vue warn]: Duplicate keys detected: ‘0’. This may cause an update error(错误,检测到重复的key值 ...
- ElementUI使用v-if控制tab标签显示遇到的Duplicate keys detected: 'xxx'问题
今天工作遇到一个问题: 需求背景:页面中有几个tab,需要根据登录用户的权限控制tab标签的显示与隐藏 . <el-tabs @tab-click="handleClick" ...
- /usr/include/sys/types.h:62: error: conflicting types for ‘dev_t’
/usr/include/sys/types.h:62: error: conflicting types for ‘dev_t’/usr/include/linux/types.h:13: erro ...
- ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
use mysql mysql> select host, user from user; 将相应用户数据表中的host字段改成'%': update user set host='%' whe ...
- ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY'
OS: centos 6.3DB: 5.5.14 测试创建yoon测试表,没有主键,没有索引,基础数据内容如下: mysql> select * from yoon;+----+-------- ...
- DataBinding注意事项Error parsing XML: duplicate attribute以及如何在listview中使用DataBinding
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- openwrt编译e2fsprogs-1.43时报错misc/create_inode.c:399:18: error: conflicting types for 'copy_file_range'
1. 详细报错信息 misc/create_inode.c:399:18: error: conflicting types for 'copy_file_range' static errcode_ ...
随机推荐
- 【转】SQL 常用关键字释义和用法
转自: http://blog.csdn.net/iamwangch/article/details/8093933 下面 是 从网络上整理 出来的 SQL 关键字和 常用函数的 释义和简单用 ...
- Python2.7-Queue
Queue 模块,python3中为queue,一般和threading模块同时使用,用于处理多任务队列,模块定义了3种队列类,先进先出(FIFO),后进先出(LIFO),优先级队列 Queue.Qu ...
- css 字体、文本、padding的样式
一.字体的样式: 1)字体倾斜:font-style:italic 2)字体大小:font-size 一般为偶数. 3)行高:line-height 当行高为奇数的时候,是文字上面比文字下面的少一 ...
- java基础设计模式1——单例模式
概念:在应用这个模式时,单例对象的类必须保证只有一个实例存在.许多时候整个系统只需要拥有一个的全局对象,这样有利于我们协调系统整体的行为. 单例模式从实现上可以分为饿汉式单例和懒汉式单例两种,前者天生 ...
- loadrunner中pacing的设置
通常我们在谈到一个软件的“性能”的时候,首先想到的就是“响应时间”和“并发用户数”这两个概念.我们看到的性能需求经常都是这样定义的: “要求系统支持 100 个并发用户” 看到这样的性能需求,我们往往 ...
- java.lang.RuntimeException: Fail to connect to camera service
玩自定义照相机的时候出现了:java.lang.RuntimeException: Fail to connect to camera service 讲过百度和Google后知道是权限少加了.(试验 ...
- Android 混淆打包
有些时候我们希望我们自己的apk包不能被别人反编译而获取自己的源代码.这就需要我们通过Android提供的混淆打包技术来完成. 一.没有引用外部包的情况: 这种情况下代码混淆的方式相对简单: 1)只需 ...
- Docker:一个装应用的容器
一:简介:你是否经历过“我本地运行没问题啊!““哪个哥们有写死循环了““完了,服务器撑不住了“等等问题,docker就是这么帮你解决问题的工具,它可以帮你把web应用自动化打包和发布,在服务型环境下进 ...
- 20155318 Exp1 PC平台逆向破解(5)M
20155318 Exp1 PC平台逆向破解(5)M 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何用户输入 ...
- AngularJS+bootstrap-switch 实现开关控件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...