Adding Web API and API documentation to an existing MVC project
asp.net-web-api, c#
Solution
As others have already said, you must first install the NuGet package `Microsoft.AspNet.WebApi.HelpPage`. This will create a new HelpPage Area in your application with the views, models and controllers required to display the documentation.
However, the HelpController that is generated contains an overloaded constructor:
public HelpController(HttpConfiguration config)
{
Configuration = config;
}
This doesn't seem to play well with Unity (or probably any kind of DI container). You get this error:
[InvalidOperationException: The type String cannot be constructed. You must configure the container to supply this value.]
Remove this overload and it should work.
Also just found another reference to this: http://www.stefan-scheller.com/2013/08/the-type-string-cannot-be-constructed-web-api-with-unity/
Problem
I have successfully added a `web api controller` to an existing `MVC4` application. I would like to have the api documentation functionality as is available in the new web api samples `(ex. http://sample.hostname.com/help)`. I believe these use the `ApiExplorer` class. I tried just copying the `HelpPage` area into my project, but I get an error "The type String cannot be constructed. You must configure the container to supply this value" when I try to navigate to help. What must I do to add automated documentation of the API?