Skip to content

Commit f7de3d1

Browse files
authored
Add note about filter_path and deserialization (#3379)
This commit adds a note to the filter_path XML comments to warn about response filtering potentially affecting deserialization to the respective response type. Include XML comments on common options for Descriptor types Closes #3331
1 parent 8570faf commit f7de3d1

File tree

6 files changed

+27
-8
lines changed

6 files changed

+27
-8
lines changed

src/CodeGeneration/ApiGenerator/Domain/ApiQueryParameters.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ public IEnumerable<string> DescriptionHighLevel
101101
case "_source":
102102
yield return "Whether the _source should be included in the response.";
103103
yield break;
104+
case "filter_path":
105+
yield return this.Description;
106+
yield return "<para>Use of response filtering can result in a response from Elasticsearch ";
107+
yield return "that cannot be correctly deserialized to the respective response type for the request. ";
108+
yield return "In such situations, use the low level client to issue the request and handle response deserialization</para>";
109+
yield break;
104110
default:
105111
yield return this.Description;
106112
yield break;

src/CodeGeneration/ApiGenerator/RestSpecification/Core/_common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"filter_path": {
2525
"type": "list",
26-
"description": "A comma-separated list of filters used to reduce the respone."
26+
"description": "A comma-separated list of filters used to reduce the response."
2727
}
2828
}
2929
}

src/CodeGeneration/ApiGenerator/Views/_Descriptors.Generated.cshtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ namespace Nest
2424
var original = common.QueryStringKey;
2525
var t = @common.TypeHighLevel;
2626
var tSuffix = (t == "bool" || t == "bool?") ? " = true" : "";
27-
<text> public TDescriptor @(common.ClsName)(@common.TypeHighLevel @common.ClsArgumentName@tSuffix) => Qs("@original", @(common.ClsArgumentName));
28-
</text>
27+
<text> ///<summary>@(Raw(string.Join("", common.DescriptionHighLevel)))</summary>
28+
public TDescriptor @(common.ClsName)(@common.TypeHighLevel @common.ClsArgumentName@tSuffix) => Qs("@original", @(common.ClsArgumentName));
29+
</text>
2930
}
3031
}
3132
@foreach (CsharpMethod method in Model.CsharpMethodsWithQueryStringInfo)

src/Nest/CommonAbstractions/Request/RequestBase.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ public IRequestConfiguration RequestConfiguration
8181
}
8282
}
8383

84+
///<summary>
85+
/// Base class for all Request descriptor types
86+
///</summary>
8487
public abstract partial class RequestDescriptorBase<TDescriptor, TParameters, TInterface> : RequestBase<TParameters>, IDescriptor
8588
where TDescriptor : RequestDescriptorBase<TDescriptor, TParameters, TInterface>, TInterface
8689
where TParameters : RequestParameters<TParameters>, new()

src/Nest/_Generated/_Descriptors.generated.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ namespace Nest
1212
{
1313
public abstract partial class RequestDescriptorBase<TDescriptor, TParameters, TInterface>
1414
{
15+
///<summary>Pretty format the returned JSON response.</summary>
1516
public TDescriptor Pretty(bool? pretty = true) => Qs("pretty", pretty);
16-
public TDescriptor Human(bool? human = true) => Qs("human", human);
17-
public TDescriptor ErrorTrace(bool? errorTrace = true) => Qs("error_trace", errorTrace);
18-
public TDescriptor FilterPath(string[] filterPath) => Qs("filter_path", filterPath);
19-
}
17+
///<summary>Return human readable values for statistics.</summary>
18+
public TDescriptor Human(bool? human = true) => Qs("human", human);
19+
///<summary>Include the stack trace of returned errors.</summary>
20+
public TDescriptor ErrorTrace(bool? errorTrace = true) => Qs("error_trace", errorTrace);
21+
///<summary>A comma-separated list of filters used to reduce the response.<para>Use of response filtering can result in a response from Elasticsearch that cannot be correctly deserialized to the respective response type for the request. In such situations, use the low level client to issue the request and handle response deserialization</para></summary>
22+
public TDescriptor FilterPath(string[] filterPath) => Qs("filter_path", filterPath);
23+
}
2024

2125
///<summary>descriptor for Bulk <pre>http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html</pre></summary>
2226
public partial class BulkDescriptor : RequestDescriptorBase<BulkDescriptor,BulkRequestParameters, IBulkRequest>, IBulkRequest

src/Nest/_Generated/_Requests.generated.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ public abstract partial class PlainRequestBase<TParameters>
2020
public bool? Human { get => Q<bool?>("human"); set => Q("human", value); }
2121
///<summary>Include the stack trace of returned errors.</summary>
2222
public bool? ErrorTrace { get => Q<bool?>("error_trace"); set => Q("error_trace", value); }
23-
///<summary>A comma-separated list of filters used to reduce the respone.</summary>
23+
///<summary>
24+
/// A comma-separated list of filters used to reduce the response.
25+
/// <para>Use of response filtering can result in a response from Elasticsearch
26+
/// that cannot be correctly deserialized to the respective response type for the request.
27+
/// In such situations, use the low level client to issue the request and handle response deserialization</para>
28+
///</summary>
2429
public string[] FilterPath { get => Q<string[]>("filter_path"); set => Q("filter_path", value); }
2530
}
2631

0 commit comments

Comments
 (0)