Not supported by Swagger 2.0: Multiple operations with path

后端 未结 9 2328
盖世英雄少女心
盖世英雄少女心 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:27

    An answer I haven't seen: I bungled up usings.

    My controller has some MVC items (List items) and thus has a link:

    using System.Web.Http;
    using System.Web.Mvc;
    

    Because of this, somehow, it got registered twice (I assume). Problem was fixed by using the full qualification for RoutePrefix/Route/HttpGet and others.

    namespace MyNameSpace
    {
        [System.Web.Http.RoutePrefix("api/Reports")]
        public class ReportsController
        {
            {...constructor...}
    
            [System.Web.Http.Route("Scans")]
            [System.Web.Http.HttpGet,ResponseType(typeof(List))]
            public ascyn Task GetScans() {...}
    

提交回复
热议问题