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_ ...
随机推荐
- centos 7 163 yum 源 python 2.7.5
安装 repo 源. repo 源一般包括 base, updates, Extras 三部分. $ cd /etc/yum.repos.d/ $ wget http://mirrors.163.co ...
- 6-51单片机ESP8266学习-AT指令(8266TCP服务器--做自己的AndroidTCP客户端发信息给单片机控制小灯的亮灭)
http://www.cnblogs.com/yangfengwu/p/8776712.html 先把源码和资料链接放到这里 链接: https://pan.baidu.com/s/1jpHZjW_7 ...
- Hadoop集群nodes unhealthy解决方法
在搭建好Hadoop集群之后,所有服务均可正常启动,但是在运行MapReduce程序的时候,发现任务卡在7/09/07 22:28:14 INFO mapreduce.Job: Running job ...
- Android Studio常用快捷键 - 转
Android Studio常用快捷键 1. Ctrl+D: 集合了复制和粘贴两个操作,如果有选中的部分就复制选中的部分,并在选中部分的后面粘贴出来,如果没有选中的部分,就复制光标所在的行,并在此行的 ...
- 2017-2018-2 《网络对抗技术》 20155319 第二周 Exp1 PC平台逆向破解(5)M
2017-2018-2 <网络对抗技术> 20155319 第二周 Exp1 PC平台逆向破解(5)M 一.实践目标 1.1实践介绍 本次实践的对象是一个名为pwn1的linux可执行文件 ...
- python 回溯法 子集树模板 系列 —— 8、图的遍历
问题 一个图: A --> B A --> C B --> C B --> D B --> E C --> A C --> D D --> C E -- ...
- BYTE数组与16进制字符串互转
//字节数组转换为HEX 字符串const string Byte2HexString(const unsigned char* input, const int datasize) { ]; ; j ...
- Dynamics 365 支持使用Web Api 通过名称来检索元数据
关键检索元数据我在之前的一篇博文中稍有提及,当时是为了取实体的picklist字段的属性,但当时的版本只支持通过metadataid检索,而在365中又增加了名称的检索,方便了很多. 本篇依旧用之前博 ...
- dotnet core webapi 发布部署到docker的步骤
1. 创建web api项目,编译并测试成功 2. 在项目的根目录添加Dockerfile文件,注意:Dockerfile文件名区分大小写 文件内容如下 # 基于microsoft/dotnet:la ...
- python3获取主机名、主机IP
python3可以通过socket模块获取主机名及主机IP 代码如下: *********************************************************** 学习永远 ...