0
/// <summary>
/// Gets activity logs.
/// </summary>
/// <param name="locationId">Location id.</param>
/// <param name="filter">Activity log filter options.</param>
/// <response code="200">OK</response>
[ResponseType(typeof(ActivityLogResponse))]
public async Task<HttpResponseMessage> FetchActivityLogs(int locationId, ActivityLogFilterOptions filter)
{
}
ActivityLogFilterOptions
有一些要求的特性和一些是可选的。有没有什么方法可以在Swagger UI API参数中指出这一点?
ActivityLogFilterOptions类:
/// <summary>
/// Represents an activity log filter options.
/// </summary>
public class ActivityLogFilterOptions
{
/// <summary>
/// Gets or sets the device ids to which the activity logs to be fetched.
/// </summary>
public string DeviceIds { get; set; }
/// <summary>
/// Gets or sets the start date for of the search.
/// </summary>
[DateTimeCompare("ToDate",
ValueComparison.IsLessThan, ErrorMessage = "From date must be earlier than end date.")]
public DateTime? FromDate { get; set; }
/// <summary>
/// Gets or sets the end date for the search.
/// </summary>
[DateTimeCompare("FromDate",
ValueComparison.IsGreaterThan, ErrorMessage = "To date must be later than from date.")]
public DateTime? ToDate { get; set; }
/// <summary>
/// Gets or set the page index.
/// </summary>
[Required]
[Range(0, int.MaxValue)]
public int? PageIndex { get; set; }
/// <summary>
/// Gets or sets the maximum record count per page.
/// </summary>
[Required]
[Range(1, short.MaxValue)]
public int? RecordsPerPage { get; set; }
/// <summary>
/// Gets or sets the activity log groups.
/// </summary>
public string Groups { get; set; }
}
如果'YourProperty'是我的API的直接参数,但在我的情况下ActivityLogFilterOptions是输入参数,并且ActivityLogFilterOptions的其中一个属性是可选的。 – JerryGoyal
您可以通过单击“参数”部分的“数据类型”列中的“模型”而不是“示例值”来查看模型上属性的可选性。 – strickt01
嘿,工作!我太傻了。 – JerryGoyal