簡體   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