【问题标题】:Asp.NET Web API : Help Description not generated for classes in referenced projectAsp.NET Web API:未为引用项目中的类生成帮助说明
【发布时间】:2015-12-11 11:55:33
【问题描述】:

我能够设置 Web API 帮助,它确实会生成帮助页面。但是,具有不同项目中定义的类型属性的响应和请求类类型没有记录。

这是示例代码:

    /// <summary>
    /// Add New Product
    /// </summary>
    /// <param name="productRequest">The new Product Request to be added</param>
    /// <returns>Operation status and information of the new product request</returns>
    // POST api/InventorySystem/Products
    [Route("")]
    [HttpPost]
    public InsertProductResponse Post([FromBody]InsertProductRequest productRequest)
    {
        InsertProductResponse response = null;

        // Some code goes here
        response = new InsertProductResponse ();

        return response;
    }

帮助页面确实包含描述“添加新产品”。但是,当深入到“InsertProductResponse”对象时,没有描述。

InsertProductResponse 在单独的类库中定义,并且为此类定义了 XML 文档。但在帮助页面上看不到。

我认为类库生成的 XML 文档没有与 Web API 项目 (App_Data/XmlDocument.xml) 生成的 XML 文档合并。我该如何让它发挥作用?

【问题讨论】:

  • 看来这个错误可能是你的 [Route("")] 属性为空造成的。您是否尝试过删除此属性并仅使用默认路由?

标签: asp.net-mvc-5 asp.net-web-api2


【解决方案1】:

知道了 - 帮助区域中的一些代码需要更改。参考这篇文章

How can Xml Documentation for Web Api include documentation from beyond the main project?

【讨论】:

    猜你喜欢
    • 2015-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-07
    • 1970-01-01
    • 2014-06-03
    • 1970-01-01
    相关资源
    最近更新 更多