Not supported by Swagger 2.0: Multiple operations with path

后端 未结 9 2261
盖世英雄少女心
盖世英雄少女心 2020-12-29 03:15

I have integrated swagger in WebApi 2 application. It works fine when application has single controller. When I added second controller in the application. I got following

相关标签:
9条回答
  • 2020-12-29 03:34

    Sorry, I answered it too late: the solution to the problem is to remove any route versioning attribute on the controller if you have more than one controller; the swagger picks route from the WebApiConfig by default. Note: You do not need to provide the action name or the route. Just make sure that no two actions have the same name nor signature; of course, it can never compile.

    0 讨论(0)
  • 2020-12-29 03:39

    I understand this is an old thread. And im straying away from the OP Issue slightly. However i recently had this issue and spent a long time trying to figure out what was happening (this page is top of google for the issue). and it may help other from going through hours of pain.

    my controllers all extended a base controller and i stupidly had a public function instead of a protected function. So swagger was picking up the public function as a duplicate.

    Hope this helps others from spending unnecessary time.

    0 讨论(0)
  • 2020-12-29 03:40

    Add seperate route on your conflicting methods. Such as [Route("GetByType")] above of one and [Route("GetById")] on another

    0 讨论(0)
提交回复
热议问题