使用Web API并使用swashbuckle生成swagger文档,我在两个不同的命名空间中定义了两个具有相同名称的不同类。当我在浏览器中打开swagger页面时,它说:

1 Conflicting schemaIds: Duplicate schemaIds detected for types A and B. See the config setting - "UseFullTypeNameInSchemaIds" for a potential workaround

完整消息:

 1 {
 2     "message": "An error has occurred.",
 3     "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",
 4     "exceptionType": "System.InvalidOperationException",
 5     "stackTrace": " 在 Swashbuckle.Swagger.SchemaRegistry.CreateRefSchema(Type type)\r\n
 6      在 Swashbuckle.Swagger.SchemaRegistry.CreateInlineSchema(Type type)\r\n
 7      在 Swashbuckle.Swagger.SchemaRegistry.GetOrRegister(Type type)\r\n
 8      在 Swashbuckle.Swagger.SwaggerGenerator.CreateOperation(ApiDescription apiDesc, SchemaRegistry schemaRegistry)\r\n
 9      在 Swashbuckle.Swagger.SwaggerGenerator.CreatePathItem(IEnumerable`1 apiDescriptions, SchemaRegistry schemaRegistry)\r\n
10      在 Swashbuckle.Swagger.SwaggerGenerator.<>c__DisplayClass7.<GetSwagger>b__4(IGrouping`2 group)\r\n
11      在 System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)\r\n
12      在 Swashbuckle.Swagger.SwaggerGenerator.GetSwagger(String rootUrl, String apiVersion)\r\n
13      在 Amo.Client.CachingSwaggerProvider.GetSwagger(String rootUrl, String apiVersion) 位置 E:\\codes\\USDTSolution\\Amo.Client\\App_Start\\SwaggerConfig.cs:行号 301\r\n
14      在 Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n
15      在 System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n
16      在 System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n
17      在 System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n 在 System.Web.Http.HttpServer.<SendAsync>d__24.MoveNext()"
18 }

我不想改变类的名字。我该如何解决?

解决方法1:

1  services.ConfigureSwaggerGen(options =>
2    {
3        //your custom configuration goes here
4
5 ...
6
7   // UseFullTypeNameInSchemaIds replacement for .NET Core
8        options.CustomSchemaIds(x => x.FullName);
9    });

解决方法2:

 1 GlobalConfiguration.Configuration
 2     .EnableSwagger(c =>
 3     {
 4         // your configs...
 5
 6         c.SchemaId(x => x.FullName);
 7
 8         // other configs...
 9     })
10     .EnableSwaggerUi(c =>
11         // ....
12     });

解决方法3:

1 c.UseFullTypeNameInSchemaIds();

swagger error: Conflicting schemaIds: Duplicate schemaIds detected for types A and B相关推荐

  1. [Vue warn]: Duplicate keys detected: ‘0‘. This may cause an update error.

    [Vue warn]: Duplicate keys detected: '0'. This may cause an update error. 刚开始看到这个问题我还有点奇怪,因为只在for循环哪 ...

  2. Duplicate keys detected: '0'. This may cause an update error.

    运行vue项目的时候,出现了[Vue warn]: Duplicate keys detected: '0'. This may cause an update error(错误,检测到重复的key值 ...

  3. vue学习中遇到的错误 Duplicate keys detected: ‘[object Object]‘. This may cause an update error.

    前端入门自学,说错的请大神指点. Avoid using non-primitive value as key, use string/number value instead. Duplicate ...

  4. Duplicate keys detected: ‘checks‘. This may cause an update error. found in

    Duplicate keys detected: 'checks'. This may cause an update error. 1.怎么查看报错 2.分析报错的原因 3.怎么修改这样的报错 4. ...

  5. Duplicate keys detected: ‘gggggg‘. This may cause an update error.的解决办法

    vue项目中报了一个这样的错:Duplicate keys detected: 'gggggg'. This may cause an update error. 虽然不影响使用吧,但是一直冒红也不太 ...

  6. Vue中报“Duplicate keys detected: ‘xxx‘. This may cause an update error.”的解决办法

    在Vue中遇到"Duplicate keys detected: 'xxx'. This may cause an update error."这样的错误提示,最有用的解决办法,亲 ...

  7. error: missing or invalid dependency detected while loading class file 'RDD.class'.

    问题重现如下: error: missing or invalid dependency detected while loading class file 'RDD.class'. Could no ...

  8. 工作194:vue.runtime.esm.js?2b0e:619 [Vue warn]: Duplicate keys detected: ‘/system‘. This may cause an

    错误如下 拿到公司一个小哥哥的代码,一来就报了一堆bug,吓得我先写一篇博客vue.runtime.esm.js?2b0e:619 [Vue warn]: Duplicate keys detecte ...

  9. vue.runtime.esm.js?2b0e:619 [Vue warn]: Duplicate keys detected: ‘xxx‘. This may cause an update err

    vue.runtime.esm.js?2b0e:619 [Vue warn]: Duplicate keys detected: 'xxx'. This may cause an update err ...

最新文章

  1. php 删除xls文件,使用PHPExcel将xls文件转换为xlsx时出错
  2. linux手写数字识别opencv,opencv实现KNN手写数字的识别
  3. php用ajaxs上传图片_php+ajax实现图片文件上传功能实例
  4. PYTHON之路(四)
  5. methods中axios里的数据无法渲染到页面
  6. leetcode 501. 二叉搜索树中的众数 思考分析
  7. 论文浅尝 | 基于Universal Schema与Memory Network的知识+文本问答
  8. 文件与流 -- fopen/fclose
  9. 2月份全球制造业PMI为55.6% 已连续8个月保持在50%以上
  10. 同样是程序员,他转行在新加坡卖鱼走向巅峰!
  11. 浏览器控制台console
  12. Android MediaCodec实现多段音视频的截取与拼接
  13. Oracle编译小结,20090525 Oracle知识总结
  14. CodeForces914 D.Bash and a Tough Math Puzzle(线段树)
  15. current,present,recent 都是现在的,都是形容词
  16. 【EMNLP 2021】SimCSE:句子嵌入的简单对比学习 【CVPR 2021】理解对比学习损失函数及温度系数
  17. JavaScript 基础知识点
  18. su组件在什么窗口_草图大师Sketchup全窗口显示快捷键是什么呢?
  19. 数据输入、转换、展示和存储 - 网络统计学类函数(1)
  20. 深度学习之目标检测与目标识别

热门文章

  1. 与Jeff Sutherland谈敏捷领导力
  2. MySQL的用户和权限介绍
  3. php ×××号码效验码生成函数
  4. Linux统计文件行数
  5. IT建设的4化(转载)
  6. SpringIOC注解的学习笔记(一)
  7. spark-submit的参数名称解析
  8. 从SEO效果看谷歌百度360搜狗有道bing技术现状
  9. copy一下面试题目
  10. 《背包问题》 动态规划