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_ ...
随机推荐
- easyui 如何引入
一:引入easyui 1:参考官网:http://www.jeasyui.net/ 2:引入 整个文件夹:themes,包括:icon.css.image 等等 3:引入easyui.css ...
- ORA-02291: 违反完整约束条件 - 未找到父项关键字
由于大意,在设置数据库表时将外键字段的类型与外键表的主键字段类型不一致,造成此错误. 我的情况是: 1.将一个为number(10)的外键设置成了number(19) 2.将外键字段对应的主键表设置成 ...
- 相亲神器记录Swift1.2
这个简单APP是用swfit1.2写的,主要重点是:1.点击键盘return键可退出键盘. 2.各个控件值的传递. Storyboard界面设计: View代码: import UIKit class ...
- C++STL之Vector的应用
这是我第一次写博客,请多指教! vector是一种向量容器,说白了就是可以改变大小的数组. vector是一个模板类,如果直接这样会报错: vector a; //报错,因为要指定模板. 需要像这样: ...
- 2015531 网络攻防 Exp1 PC平台逆向破解(5)M
2015531 网络攻防 Exp1 PC平台逆向破解(5)M 实践目标 本次实践的对象是linux的可执行文件 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何用户输入的字符串 ...
- mount状态下表空间情报试验
SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> sta ...
- Hadoop日记Day14---MapReduce源代码回顾总结
一.回顾单词统计源码 package counter; import java.net.URI; import org.apache.hadoop.conf.Configuration; import ...
- vector 去重
1.使用unique函数: sort(v.begin(),v.end()); v.erase(unique(v.begin(), v.end()), v.end()); //unique()函数将重复 ...
- libgdx学习记录9——FreeType,ttf中文显示
前面讲到使用Hireo创建的BitmapFont以显示中文字体.这种方式效率很高,当所要显示的字的总数较少,并且大小比较固定时,可以采用这种方式. 但是这种也有弊端: (1)字体大小不能随意设置,当放 ...
- Markdown 入门指南
导语: Markdown是一种轻量级的标记语言,语法简单,学习成本不算太高,但确实可以让你专注于文字,不用太分心与排版等等. Markdown 官方文档 这里可以看到官方的Markdown语法规则: ...