ASP.NET Web API Swagger (Swashbuckle) Duplicate OperationId

a 夏天 提交于 2019-12-24 07:45:41

问题


I have a web api controller like below. In swagger output I am having the below image And when I want to consume it in my another console app, it is showing the below error

Note I have followed the tutorial Customize Swashbuckle-generated API definitions but still getting the same error. Any idea?


回答1:


I must need to add the Route Attribute on top of the Action methods. Like below: So, the API changed into below Swagger UI endpoints And when I consumed this Swagger in my console app, the below OperationId I got And I can now call like below (just an example)




回答2:


I found this while looking for the same question. For me it was a dumb mistake: the controller's methods had the same name. Apparently, Swashbuckle uses the method's name as the Operation Id.



来源:https://stackoverflow.com/questions/39843269/asp-net-web-api-swagger-swashbuckle-duplicate-operationid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!