2016-11-24 62 views
2

我正在使用Swashbuckle 5.5.3和使用XMLComments定制的API文档。我已经提供了未在API文档中编辑过的模型属性的描述。XMLCOMMENTS中的模型参数描述

示例代码:

/// <summary> 
/// SomeDetails. 
/// </summary> 
/// <param name="Model">SomeDetails.</param> 
/// <param name="Model.UserName">SomeDetails of username.</param> 
/// <param name="Model.OwnerId">SomeDetails.</param> 

enter image description here

它显示了总结,我放到了首位,但不显示模型属性的细节。

+0

你有什么行动PARAMS?在截图中,我看到两个参数:userName和ownerId,而我没有看到任何你描述的“Model”对象。 –

+0

MethodName([FromUri(Name =“”)] ModelName model) 这就是为什么你看不到模型。 –

+0

如果您使用模型对象作为输入,那么描述将取自ModelName类的属性(如UserName,OwnerId等)中提供的文档 –

回答

2

SwashBuckle documentation中所述,您必须将自己的参数描述放在属性上,而不是作为方法上的参数。

在你的情况,这意味着有这样一个模型:

public class Model 
{ 
    /// <summary> 
    /// user Name (e.g. ...) 
    /// </summary> 
    public string UserName { get; set; } 

    /// <summary> 
    /// Id of the owner in context of... 
    /// </summary> 
    public int OwnerId { get; set; } 
}