Microsoft Web API帮助页面 - 如何创建参数注释 [英] Microsoft Web API Help page - how to create annotations for parameters
问题描述
经过一些查看标记后,我发现这个信息应该从属性到达$ /
< td class =parameter-annotations>
@if(parameter.Annotations.Count> 0)
{
foreach(parameter.Annotations中的var annotation)
{
< p> @annotation。文档和LT; / p为H.
}
}
else
{
< p>无。< / p>
}
< / td>
但是,我应该使用什么样的属性来填充其他信息?
谢谢
请参阅本网站,了解如何添加附加信息。
它基本上是注释你的模型,所以在你的情况下,它将是这样的: -
public class Product
{
///< summary>
///产品的ID
///< / summary>
[必需]
public int Id {get;组; }
///< summary>
///产品名称
///< / summary>
[MaxLength(50)]
public string Name {get;组; }
}
哪个会给你这样的输出: -
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:-
这篇关于Microsoft Web API帮助页面 - 如何创建参数注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!