I installed ASP.NET 4 Web API Help Page package via nuget to my Web Api project. For some reason it does not display all the api endpoints. I have the documentation set to use XML. Not sure why this is happening, any help is appreciated.
Here is an example controller
public class ProductController : BaseController
{
// GET api/Product/Get/5/43324
[AcceptVerbs("GET")]
public ApiProduct Get(int id, [FromUri]int productId)
{
//// logic
}
}
routes
config.Routes.MapHttpRoute(
name: "api-info",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional, action = RouteParameter.Optional }
);
Thanks
I figured out the issue, the problem here is, In Web API there is no action and methods are mapped to the verb and arguments directly, Updating my route to this fixed the problem and all the routes show up.
config.Routes.MapHttpRoute(
name: "apsi-info",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
If the above solution doesn't solve your problem - take a look and make sure you aren't defining BOTH the AcceptVerbs attribute and its shortcut:
public class ProductController : BaseController
{
// GET api/Product/Get/5/43324
[AcceptVerbs("GET")]
[HttpGet]
public ApiProduct Get(int id, [FromUri]int productId)
{
//// logic
}
}
Remove one of them and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With