不会破坏帮助文档网站的 WebAPI 2 return 类型
WebAPI 2 return types that don't break the help documentation website
有没有办法在不破坏超级方便的帮助文档的情况下为我的 API 方法使用(显然首选的)IHttpActionResult return 类型?当我 return
List<T>
从我的方法中,我得到了非常详细的帮助文档。当我 return IHttpActionResult 时,我得到无用的帮助文档。为什么给我们一个这么酷的玩具,然后建议我们使用会破坏玩具的东西?我是否缺少有关如何将文档网站与 MS 首选样式一起使用的重要资源?
您应该可以在它生成文档时附加 ResponseTypeAttribute to your action methods which specifies the expected return type when using HttpResponseMessage
or IHttpActionResult
. This should then be picked up by ApiExplorer。
来自网站:
Use this to specify the entity type returned by an action when the declared return type is HttpResponseMessage or IHttpActionResult. The ResponseType will be read by ApiExplorer when generating ApiDescription.
如果您使用另一个 API 生成文档,您应该检查他们是否支持它或将其包含在问题中,也许这里有人知道。
有没有办法在不破坏超级方便的帮助文档的情况下为我的 API 方法使用(显然首选的)IHttpActionResult return 类型?当我 return
List<T>
从我的方法中,我得到了非常详细的帮助文档。当我 return IHttpActionResult 时,我得到无用的帮助文档。为什么给我们一个这么酷的玩具,然后建议我们使用会破坏玩具的东西?我是否缺少有关如何将文档网站与 MS 首选样式一起使用的重要资源?
您应该可以在它生成文档时附加 ResponseTypeAttribute to your action methods which specifies the expected return type when using HttpResponseMessage
or IHttpActionResult
. This should then be picked up by ApiExplorer。
来自网站:
Use this to specify the entity type returned by an action when the declared return type is HttpResponseMessage or IHttpActionResult. The ResponseType will be read by ApiExplorer when generating ApiDescription.
如果您使用另一个 API 生成文档,您应该检查他们是否支持它或将其包含在问题中,也许这里有人知道。