I installed the ASP.NET Web API Help Page package and would like to use it to generate documentation for my API controller actions using the Xml comments already on them.
I came across an article on Yao's MSDN blog where he discusses how the documentation can be generated based on the XML comments.
However, in the Register method of HelpPageConfig
, the SetDocumentationProvider
method expects an instance of XmlDocumentationProvider
constructed with a physical path to an Xml documentation file.
Is there another way to do this? I'm not clear why I need to point to an Xml documentation file.
Thanks
Now enable XML documentation. In Solution Explorer, right-click the project and select Properties. Select the Build page. Under Output, check XML documentation file.
You can enable generating this by going to your project Properties -> Build -> Output. Here select the checkbox for XML Documentation file.
NuGet packages (36) A simple Test Client built on top of ASP.NET Web API Help Page.
XML comments help speed development by providing IntelliSense on custom methods and other code constructs. XML comments encourage code reuse by providing a path to generate API style reference documentation from your source code.
If you still problem then see below steps.
Step 1 - Add comment on the controller level
// GET api/documentation /// <summary> /// This is how we create a documentation /// </summary> /// <returns></returns> public IEnumerable<string> Get()
Step 2 - Build Property Project Properties page and set up the xml output for documentation
Step 3 - HelpPage Config
To set up the HelpPageConfig to use our documentation xml file, go to ~\Areas\HelpPage\HelpPageConfig.cs
.
By default, the config.SetDocumentationProvider statement is commented out. Use that statement, and point the location of DocumentationProvider to our xml file:
public static void Register(HttpConfiguration config) { // Uncomment the following to use the documentation from XML documentation file. config.SetDocumentationProvider( new XmlDocumentationProvider( HttpContext.Current.Server.MapPath("~/App_Data/Documentation.xml"))); }
EDIT:
The location of the HelpPageConfig in a new Web API 2.2 project created in VS2013 is ~\Areas\HelpPage\App_Start\HelpPageConfig.cs
The XmlDocumentationProvider is looking for the xml file(having your xml code comments) which gets generated when you compile your project. You can enable generating this by going to your project Properties -> Build -> Output. Here select the checkbox for XML Documentation file.
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