0

My .Net MVC project has the below ApiController:

enter image description here

But the Swagger UI generates two methods:

enter image description here

Observe that the ActionName TestMethod1 is omitted(probably because there is only one HttpGet in this controller)

  • There must be something else, the code you show here should not cause that issue, create a new project that can reproduce this and paste a link I would be happy to look into it – Helder Sepulveda Dec 19 '20 at 17:04

1 Answers1

0

This was due to the DefaultRoute not having the {action} in the path.

 routes.MapRoute(
                name: "Default",
                url: "{controller}/{id}",
                defaults: new { controller = "Addon", action = "Index", id = UrlParameter.Optional }
            );

It should be like:

 routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Addon", action = "Index", id = UrlParameter.Optional }
            );