繁体   English   中英

单独项目下的ASP.NET Web API帮助页面

[英]ASP.NET Web API Help page under separate project

我有ASP.NET Web API项目,我想添加一个帮助页面,但我希望它在一个单独的项目中。

可能吗 ?

您应该从帮助项目中的Web API项目调用WebApiConfig.Register:

  protected void Application_Start()
  {
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     GlobalConfiguration.Configure(MyApiProjectNamespace.WebApiConfig.Register);
  }

您可以将XmlDocumentationProvider构造函数重写为以下内容:

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());
    }
}

它将包括您在数组中列出的所有xml文档文件。 您还应确保目标Web API项目(以及所有模型项目,如果需要)生成有关构建的文档并将其复制到正确的位置。 在此输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM