[英]How to display parameter in Web API help page for request and response body
I want to show request and response body as parameter not as raw data.我想将请求和响应主体显示为参数而不是原始数据。 For that I have followed Generate Description Fields for Body Parameters answer but not get success, still showing为此,我遵循了 Generate Description Fields for Body Parameters 的答案,但没有成功,仍然显示
/// <summary>
/// Gets some very important data from the server.
/// </summary>
/// <param name="reqData">A Test Model</param>
[HttpPost]
public AccountService.GetAccountList_ResponseData GetAccountList([FromBody] AccountService.GetAccountList_ReqestData reqData)
{
}
//--my modal
public class GetAccountList_ReqestData
{
/// <summary>
/// StartDate
/// </summary>
/// <param name="StartDate">Describe parameter.</param>
public string StartDate { get; set; }
}
//---Also enabled
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/WebApi.xml")));
You have to add XmlDocs to your class GetAccountList_RequestData
您必须将 XmlDocs 添加到您的 class GetAccountList_RequestData
/// <summary>
/// My requestData model
/// </summary>
/// <param name="reqData">The description you want </param>
public class GetAccountList_ReqestData
{
/// <summary>
/// StartDate
/// </summary>
/// <param name="StartDate">Describe parameter.</param>
public string StartDate { get; set; }
}
You followed the steps correctly, however the person asking in the other thread was displaying a property.您正确地遵循了这些步骤,但是在另一个线程中询问的人正在显示一个属性。 You on the other hand are asking for an object, which is your class. Therefor the xmldocs of the class will be used to generate the descriptions.另一方面,您要求的是 object,这是您的 class。因此,class 的 xmldoc 将用于生成描述。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.