简体   繁体   English

WebApi2帮助页面在扩展ApiController后停止生成文档

[英]WebApi2 Help Page stops generating documentation after extending ApiController

I have extended ApiController to include some common properties/methods, and this extended controller is held in a separate class library/assembly. 我对ApiController进行了扩展,以包括一些常见的属性/方法,并且此扩展控制器位于单独的类库/程序集中。

public class ExtendedApiController : ApiController
{
    // shared properties...
}

In my Api project, all controllers inherit from this extended controller. 在我的Api项目中,所有控制器都继承自该扩展控制器。

public class HomeApiController : ExtendedApiController
{
    // actions...
}

Pretty simple... 很简单...

However, extending the base class now prevents the Help Page generator from actually generating documentation from these controllers. 但是,现在扩展基类可以防止“帮助页面”生成器实际从这些控制器生成文档。 If I switch the controllers back to inheriting directly from ApiController they are visible in the docs. 如果我将控制器切换回直接从ApiController继承,则它们将在文档中可见。

Is there a way to allow/change the assembly name the generator looks for? 有没有一种方法可以允许/更改生成器要查找的程序集名称? I have a sneaking suspicion that it is comparing a base class directly to "ApiController" and is therefore skipping all of mine. 我有一个偷偷摸摸的怀疑,它正在直接将基类与“ ApiController”进行比较,因此跳过了我的所有内容。

Well, as it turns out the fact that my base class was in a different assembly was part of the problem. 好吧,事实证明我的基类在不同的程序集中是事实的一部分。 The real issue was the fact that these projects referenced different versions of the WebApi2 libraries. 真正的问题是这些项目引用了WebApi2库的不同版本。 Unfortunately, the conflicting package version was only listed as a warning, not an error, so I missed it. 不幸的是,有冲突的软件包版本仅被列为警告,而不是错误,因此我错过了它。 An update of all NuGet packages across all projects in the solution fixed the issue. 解决方案中所有项目中所有NuGet软件包的更新均解决了该问题。

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

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