Generating Web API Help for multiple assemblies RRS feed

  • Question

  • User-638259267 posted

    I read this article and I am using Xml Comments for my Web API Help Pages: http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/creating-api-help-pages

    However, based on the article, by making a change in my HelpPageConfig.cs file, I can only add the path to a single XmlComments file for a single assembly.  However, I would like to display the XmlComments for multiple assemblies since I am using an OWIN/Katana container and have numerous Web API service assemblies contained in the same host.

    Therefore, is there a way to accomplish this using this line in the HelpPageConfig.cs file?

    config.SetDocumentationProvider(new XmlDocumentationProvider(GetXmlCommentsFilePath()));

    Please advise.


    Thursday, March 10, 2016 4:45 AM


  • User36583972 posted

    Hi vs2010junkie

    As far as I know, you can try to load XmlComments from different files through the following two methods.

    1: You can modify the XmlDocumentationProvider constructor to let it supports multiple files.


    /// <summary>
            /// Initializes a new instance of the <see cref="XmlDocumentationProvider"/> class.
            /// </summary>
            /// <param name="documentPath">The physical path to XML document.</param>
            public XmlDocumentationProvider(string xmlDocFilesPath)
                //if (documentPath == null)
                //    throw new ArgumentNullException("documentPath");
                //XPathDocument xpath = new XPathDocument(documentPath);
                //_documentNavigator = xpath.CreateNavigator();
                XDocument finalDoc = null;
                foreach (string file in Directory.GetFiles(xmlDocFilesPath, "*.xml"))
                    if (finalDoc == null)
                        finalDoc = XDocument.Load(File.OpenRead(file));
                        XDocument xdocAdditional = XDocument.Load(File.OpenRead(file));
                // Supply the navigator that rest of the XmlDocumentationProvider code looks for
                _documentNavigator = finalDoc.CreateNavigator();


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

    2: You can load multiple files at the same time.

     config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data1/XmlDocument1.xml")));
     config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data2/XmlDocument2.xml")));

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 11, 2016 4:27 AM