微软的Web API帮助页面 - 如何创建参数注释 [英] Microsoft Web API Help page - how to create annotations for parameters

查看:390
本文介绍了微软的Web API帮助页面 - 如何创建参数注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我开始新的Web API帮助页面的功能发挥,这是最近加入到网页API项目模板。我有一个通知,一些附加信息栏始终是无。

Recently i've start playing with new web api help page functionality, that was recently added to web api project template. And i have a notice that some "Additional information" column is always 'none'.

有的在看标记后,我发现这个信息应该从属性到

After some looking at markup i found that this info should arrive from attributes

 <td class="parameter-annotations">
                    @if (parameter.Annotations.Count > 0)
                    {
                        foreach (var annotation in parameter.Annotations)
                        {
                            <p>@annotation.Documentation</p>
                        }
                    }
                    else
                    {
                        <p>None.</p>
                    }
                </td>

但我应该用什么样的属性,以填充更多的信息?
谢谢

But what kind of attribute i should use, to populate additional information? Thanks

推荐答案

请参阅本网站对于如何添加附加信息的示例。

See this site for an example of how to add additional information.

这基本上标注模型,所以在你的情况下,它会是这样: -

It's basically annotating your model, so in your case it would be something like:-

public class Product
{
    /// <summary>
    ///  The id of the product
    /// </summary>
    [Required]
    public int Id { get; set; }

    /// <summary>
    /// The name of the product
    /// </summary>
    [MaxLength(50)]
    public string Name { get; set; }
}

这会给你一个像这样的输出: -

Which would give you an output like this:-

这篇关于微软的Web API帮助页面 - 如何创建参数注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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