Web Api - Swagger 文档错误 500 [英] Web Api - Swagger documentation error 500

查看:28
本文介绍了Web Api - Swagger 文档错误 500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我访问 swagger url: http://localhost:28483/swagger/ui/index 时,它会生成这个错误:

When I access to the swagger url: http://localhost:28483/swagger/ui/index, it generates this error:

500 : undefined http://localhost:28483/swagger/docs/v1

有什么想法吗?

更新:在 firebug 中查看此详细错误:

UPDATED: See this detail error in 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

推荐答案

Swagger 可能会将两个操作视为一个操作(就像在这种常见情况下一样)...

Swagger might be considering two actions as one operation (like in the case of this common scenario)...

GET api/Products
GET api/Products/{id}

看来你可以使用 属性路由 来解决这个问题,并在您的操作上方使用这些属性,以便 swagger 将分别识别它们.

It seems you can use attribute routing to fix this and use these attributes above your actions so swagger will recognize them separately.

[Route("api/Products")]

[Route("api/Products/{id:guid}")]

这篇关于Web Api - Swagger 文档错误 500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆