So I have Web Application project (not MVC), in Global.asax.cs we didn't do RouteTable.Routes.MapHttpRoute to maps all controller.
For example, we are not using this:
i.e)
RouteTable.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
Instead, we map each method from each controller directly our self using RouteTable.Routes.MapHttpRoute.
We have following method in controller:
[HttpGet]
[ActionName("GetItemById")]
public string Get(int? id = null, int? id2 = null)
{
return "value";
}
If we use routeTemplate: "api/{controller}/{id}", this method will generate the documentation:
GET api/Items/{id}?id2={id2}
But if we define our routing on this method not using routeTemplate: "api/{controller}/{id}":
RouteTable.Routes.MapHttpRoute(name: "ItemApiById", routeTemplate: "api/Items/", defaults: new { controller = "Items", action = "GetItemById", id = RouteParameter.Optional, id2 = RouteParameter.Optional });
The documentation for this method will not be generated, because in routeTemplat doesn't contains any of the optional parameter.
But once we define:
RouteTable.Routes.MapHttpRoute(name: "ItemApiById", routeTemplate: "api/Items/{id}/{id2}", defaults: new { controller = "Items", action = "GetItemById", id = RouteParameter.Optional, id2 = RouteParameter.Optional });
The documentation will be generated.
For example, we are not using this:
i.e)
RouteTable.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
Instead, we map each method from each controller directly our self using RouteTable.Routes.MapHttpRoute.
We have following method in controller:
[HttpGet]
[ActionName("GetItemById")]
public string Get(int? id = null, int? id2 = null)
{
return "value";
}
If we use routeTemplate: "api/{controller}/{id}", this method will generate the documentation:
GET api/Items/{id}?id2={id2}
But if we define our routing on this method not using routeTemplate: "api/{controller}/{id}":
RouteTable.Routes.MapHttpRoute(name: "ItemApiById", routeTemplate: "api/Items/", defaults: new { controller = "Items", action = "GetItemById", id = RouteParameter.Optional, id2 = RouteParameter.Optional });
The documentation for this method will not be generated, because in routeTemplat doesn't contains any of the optional parameter.
But once we define:
RouteTable.Routes.MapHttpRoute(name: "ItemApiById", routeTemplate: "api/Items/{id}/{id2}", defaults: new { controller = "Items", action = "GetItemById", id = RouteParameter.Optional, id2 = RouteParameter.Optional });
The documentation will be generated.