1

I am working on a project that requires documentation on an API Help page. The page is already created, and it is ready for information to be inserted. But I have some issues:

  1. I am very new to this, so I am having some issues navigating through the project.

  2. I want to reference XML comments that are directly within the Controller files, like this:

    /// <summary>
    /// Get all the number of help desk tickets by their current priorities
    /// </summary>
    /// <returns></returns>
    
    
    [ActionName("GetCurrentPriority")]
    public TicketPriorities GetTicketsByCurrentPriority()
    {...
    

The HTTP route code in the WebApiConfig.cs file looks like this:

            config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{action}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

However, I don't know how to post the comment on the web help page. I have seen many examples where a parameter ID is used, but there appears to be no ID, and I don't know how to find the parameter ID or make it, since the Help page shows all but the ID. For example, should I create an XMLDocument.xml file and put all the comments in there?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275

1 Answers1

3

You have this line of code?

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

Also don't forget to tick "XML documentation file" in the Project Properties -> Build. Set the path to App_Data\XmlDocument.xml.

You may also want to suppress warning CS1591 since there will be plenty of classes (such as in the Help generating code) which are public but do not need documentation added to them.

See this documentation for more details: http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages

Sellorio
  • 1,806
  • 1
  • 16
  • 32
Ronnel
  • 656
  • 7
  • 9
  • I have that line uncommented, but I am unsure of where to go from there? Do the XML comments go into the XmlDocument.xml file? – Jonathan Sullivan Apr 14 '15 at 14:47
  • what you mean exactly? u have to tell vs to generate the xml for you.. Under Output, check XML documentation file. In the edit box, type “App_Data/XmlDocument.xml”. from there document you code as usual.. – Ronnel Apr 15 '15 at 00:01