2016-12-22 5 views
0

における複合入力パラメータオブジェクトの必要な特性を示しこの方法で闊歩UI

/// <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; } 
    } 

enter image description here

答えて

1

はい、あなたはそのプロパティが闊歩UIで「オプション」として表示されませんRequiredAttributeであなたのAPIモデルの性質を飾る場合:

複雑なオブジェクトの場合、「モデル」ラットをクリックすると、モデルのプロパティのオプションが表示されます"Parameters"セクションの "Data Type"列の "Example Value"よりも重要です。

+0

これは、 'YourProperty'がmy apiの直接パラメータですが、私のケースではActivityLogFilterOptionsが入力パラメータで、ActivityLogFilterOptionsのプロパティの1つがオプションです。 – JerryGoyal

+0

"Parameters"セクションの "Data Type"列の "Example Value"ではなく "Model"をクリックすると、モデルのプロパティのオプションが確認できます。 – strickt01

+0

ちょっと働いた!私の愚かなこと。 – JerryGoyal