0
votes

I am using Swagger API Documentation Utility. Please take a look at the screenshot. The Documentation lists the methods twice. Am I missing something in order to configure this correctly?

enter image description here

My controller "JobTraps" is having only one method. Still it is listed two times. One without PUT in URL and one with PUT in URL. Same thing happens for all the other controllers.

Can someone explain to me why I am facing this behavior? What should I do in order to make it work correctly ?

1
What library are you using to generate your Swagger docs? Also, how is your routing configured for your app? Do the URIs containing the HTTP verbs actually work if you call them? - Ruaidhrí Primrose
I am following this post. bitoftech.net/2014/08/25/… Please note that i had some issues in Step 2: Call the bootstrapper in “Startup” class. Bootstrapper is not available to me. So i have not followed this step. I have only enabled XML file which will be generating documentation based on annotations that i have placed in controller. And yes all http urls are working fine. - Sachin Trivedi
I am facing the same problem. Check your route config to see if the there is mapping like shown on swagger UI. - prashant

1 Answers

4
votes

I found the issue. When i go to my webApiConfig.cs file inside App_Start folder it was having route defined twice.

So i commented out the "ActionAPI" route and now swagger started showing api listing correctly.

Hope this helps some one.

 config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );



        //config.Routes.MapHttpRoute(
        //    name: "ActionApi",
        //    routeTemplate: "api/{controller}/{action}/{id}",
        //    defaults: new { id = RouteParameter.Optional, action = RouteParameter.Optional }
        //);