Search code examples
c#asp.net.netasp.net-web-apiasp.net-web-api-helppages

ASP.NET Web API Help page under separate project


I have ASP.NET Web API project and I want to add a Help page, but I want it to be in a separate project.

Is it possible ?


Solution

  • You can re-write XmlDocumentationProvider constructor to something like that:

    public XmlDocumentationProvider(string appDataPath)
    {
        if (appDataPath == null)
        {
            throw new ArgumentNullException(nameof(appDataPath));
        }
    
        var files = new[] { "MyWebApiProject.xml" /*, ... any other projects */ };
        foreach (var file in files)
        {
            var xpath = new XPathDocument(Path.Combine(appDataPath, file));
            _documentNavigators.Add(xpath.CreateNavigator());
        }
    }
    

    It will include all the xml documentation files that you list in the array. You should also make sure your target Web API project (and all the model projects if needed) generates documentation on build and copies it to the right location. enter image description here