WebApi Help Page Description

  • 79 Views
  • Last Post 25 November 2016
  • Topic Is Solved
erportico posted this 25 November 2016

What populates the Webapi method's description on the helper page and the introduction paragraph?

WebAPI Help page

  • Liked by
  • admin
admin posted this 25 November 2016

According to this article you can use XML documentation comments to create the documentation. To enable this feature, open the file Areas/HelpPage/App_Start/HelpPageConfig.cs and uncomment the following line:

config.SetDocumentationProvider(new XmlDocumentationProvider(
    HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));

Now enable XML documentation. In Solution Explorer, right-click the project and select Properties. Select the Build page. Under Output, check XML documentation file. In the edit box, type “App_Data/XmlDocument.xml”.

WebAPI output properties

Add some documentation comments to the controller methods. For example:

/// 
/// Gets some very important data from the server.
/// 
public IEnumerable Get()
{
    return new string[] { "value1", "value2" };
}

/// 
/// Looks up some data by ID.
/// 
///The ID of the data.
public string Get(int id)
{
    return "value";
}

  • Liked by
  • erportico
Close