网页API帮助页面上的资源描述正显示出"无" [英] Resource Description on Web API Help page is showing "None."

查看:286
本文介绍了网页API帮助页面上的资源描述正显示出"无"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法搞清楚如何获得帮助页面在我的Web API来显示除无其他资源说明什么。它IHttpActionResult链接,然后选择无。之后。我得到了我的样品中加入 config.SetActualResponseType(typeof运算(的ComplexType),控制器,行动)的工作; 来HelpPageConfig.cs。我的控制器看起来是这样的:

I'm having trouble figuring out how to get the Help page in my Web Api to show anything for Resource Description other than None. It has IHttpActionResult linked and then "None." after that. I got my samples working by adding config.SetActualResponseType(typeof(ComplexType), "Controller", "Action"); to HelpPageConfig.cs. My controller looks like this:

/// <summary>
/// My description
/// </summary>
[Route("MyRoute")]
public IHttpActionResult Get()
{
    try
    {
        //throw new Exception("TEST");
        return Ok(returnValue);
    }
    catch (Exception ex)
    {
        *Company Log Method*
        return NotFound();
    }
}

我不知道我从HelpPageConfig.cs否则任何地方失踪。也许一套新的眼睛能抓到的东西。在此先感谢您的帮助!

I don't know what I'm missing from HelpPageConfig.cs or any place else. Maybe a fresh set of eyes can catch something. Thanks in advance for the help!

推荐答案

我只是补充所需 [responseTyp的(typeof运算(为MyModel))] 上面包括以后我的行动使用System.Web.Http.Description; 在我的控制器的顶部。我得到我的模式现在不是IHttpActionResult和说明无。

I just needed to add [ResponseType(typeof(MyModel))] above my action after including using System.Web.Http.Description; at the top of my controller. I'm getting the description of my model now instead of IHttpActionResult and "None."

这篇关于网页API帮助页面上的资源描述正显示出&QUOT;无&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆