当我访问swagger url:http://localhost:28483/swagger/ui/index
时,它会生成以下错误:
500 : undefined http://localhost:28483/swagger/docs/v1
字符串
有什么想法吗?
错误:请参阅firebug中的此详细错误:
Not supported by Swagger 2.0: Multiple operations
with path 'api/BimModel' and method 'GET'. See the config setting - \"ResolveConflictingActions\" for
a potential workaround
型
7条答案
按热度按时间sbtkgmzw1#
Swagger可能会将两个操作视为一个操作(就像这个常见场景中的情况一样)。
字符串
看起来你可以使用attribute routing来解决这个问题,并在你的操作上使用这些属性,这样swagger就可以单独识别它们。
型
x4shl7ld2#
你试过在swagger配置中启用这个功能吗?
字符串
5ktev3wc3#
在控制器中,它有两个不同的GET操作,Swagger不允许。我建议每个控制器只有一个GET操作,或者modify the router in WebApiConfig
kmynzznz4#
我在混合属性路由和默认路由时遇到了同样的问题。当我删除默认路由时,问题就消失了。缺点是,没有定义默认路由,我必须向所有控制器添加属性路由。
所以从我的WebApiConfig中删除了:
字符串
并将属性路由添加到我的控制器:
型
实际上,我在Controller上使用
[RoutePrefix("Session")]
,在方法上使用[Route("")]
,但结果应该是一样的。dpiehjr45#
我得到这个错误是由于参数名称不匹配之间的属性路由语句和方法签名。
字符串
将“{id}”更改为“{deviceNumber}”后,它修复了错误。
bq8i3lrv6#
在我的例子中,错误是由重复的http属性引起的:
字符串
我们正在创建一个新版本的端点,所以我复制并粘贴了旧方法,重命名了函数名,忘记重命名属性:
型
当第二个属性被重新命名为新的方法时,斯瓦格又没事了。
v64noz0r7#
字符串