加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-web-api – ASP.Net Web API帮助页面:记录复杂类型属性

发布时间:2020-12-16 04:28:52 所属栏目:asp.Net 来源:网络整理
导读:我有一个post动作接收Person类型的FromBody参数.在HelpPage中,我获得有关Person paramater的信息.是否可以在Person中列出有关属性的信息,并使用 XML文档文件中的文档来获取每个属性的描述? public class PersonController : ApiController{ /// summary ///
我有一个post动作接收Person类型的FromBody参数.在HelpPage中,我获得有关Person paramater的信息.是否可以在Person中列出有关属性的信息,并使用 XML文档文件中的文档来获取每个属性的描述?
public class PersonController : ApiController
{
    /// <summary>
    /// Add a person
    /// </summary>
    /// <param name="person">Person to add</param>
    /// <returns></returns>
    [HttpPost]
    public HttpResponseMessage Add([FromBody] Person person)
    {
        // ...

        return Request.CreateResponse(HttpStatusCode.Created);
    }
}

/// <summary>
/// A person
/// </summary>
public class Person
{
    /// <summary>
    /// The name of the person
    /// </summary>
    public String Name { get; set; }

    /// <summary>
    /// The age of the person
    /// </summary>
    public Int32 Age { get; set; }
}

解决方法

目前不支持开箱即用.有一个相关的工作项,它要求为模型上使用的数据注释属性生成帮助页面.您的方案应该在其固定的后续工作: http://aspnetwebstack.codeplex.com/workitem/877

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读