I have successfully added a web api controller
to an existing MVC4
application.
I would like to have the api documentation functionality as is
My assumption is that the requirement is to provide automated documentation for Web API endpoints, not MVC endpoints. Based on that assumption, I built a POC that works as intended and I can always email you a zip if needed :).
Build a new MVC 4 Internet Application. This will generate Home and Account controllers, matching views, and MVC routing.
Add in Microsoft.AspNet.WebApi.HelpPage package by searching for "HelpPage" in the Online section of the Package Manager.
Add in a new folder for your Web API controllers called "Api". This is driven by your WebApi routing set up in the Register method of WebApiConfig.cs. Mine is as follows:
public static void Register(HttpConfiguration
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional });
}
Build the project. Hit endpoint /help. It spit out all of the end points in my api controller (a get and a post endpoint).
This did not require any changes to the area folder that is generated by adding the HelpPages package. All it required was adding a new Api folder and a new Api controller (empty) to the folder, and a quick two endpoints built out into the new controller.