Skip to content

Commit 57ab863

Browse files
committed
Do not generate parameterless ctors for Scroll and ClearScroll
1 parent 37dac5d commit 57ab863

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/CsharpMethod.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,20 @@ public static CsharpMethod Clone(CsharpMethod method)
5959
};
6060
}
6161

62-
private bool IsPartless => this.Url.Parts == null || !this.Url.Parts.Any();
63-
6462
private string MetricPrefix => this.RequestType.Replace("Request", "");
6563
private string ClrParamType(string clrType) => clrType.EndsWith("Metrics", StringComparison.OrdinalIgnoreCase)
6664
? this.MetricPrefix + clrType.Replace("Metrics", "Metric") : clrType;
6765

6866
public IEnumerable<Constructor> RequestConstructors()
6967
{
7068
var ctors = new List<Constructor>();
69+
7170
if (IsPartless) return ctors;
71+
72+
// Do not generate ctors for scroll apis
73+
// Scroll ids should always be passed as part of the request body and enforced via manual ctors
74+
if (IsScroll) return ctors;
75+
7276
var m = this.RequestType;
7377
foreach (var url in this.Url.Paths)
7478
{
@@ -272,6 +276,9 @@ public IEnumerable<FluentRouteSetter> GetFluentRouteSetters()
272276
return setters;
273277
}
274278

279+
280+
private bool IsPartless => this.Url.Parts == null || !this.Url.Parts.Any();
281+
private bool IsScroll => this.Url.Parts.All(p => p.Key == "scroll_id");
275282
public bool IndicesAndTypes => AllParts.Count() == 2 && AllParts.All(p => p.Type == "list") && AllParts.All(p => new[] { "index", "type" }.Contains(p.Name));
276283
public bool IsDocumentPath => AllParts.Count() == 3 && AllParts.All(p => p.Type != "list") && AllParts.All(p => new[] { "index", "type", "id" }.Contains(p.Name));
277284
public IEnumerable<ApiUrlPart> AllParts => (this.Url?.Parts?.Values ?? Enumerable.Empty<ApiUrlPart>()).Where(p => !string.IsNullOrWhiteSpace(p.Name));

src/Nest/_Generated/_Requests.generated.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,7 @@ public partial interface IClearScrollRequest : IRequest<ClearScrollRequestParame
833833
public partial class ClearScrollRequest : RequestBase<ClearScrollRequestParameters>, IClearScrollRequest
834834
{
835835
protected IClearScrollRequest Self => this;
836-
/// <summary>/_search/scroll</summary>
837-
public ClearScrollRequest() : base(){}
838-
839-
840-
///<summary>The URL-encoded request definition</summary>
836+
///<summary>The URL-encoded request definition</summary>
841837
public string Source { get { return Q<string>("source"); } set { Q("source", value); } }
842838

843839
///<summary>Comma separated list of filters used to reduce the response returned by Elasticsearch</summary>
@@ -4000,11 +3996,7 @@ public partial interface IScrollRequest : IRequest<ScrollRequestParameters>
40003996
public partial class ScrollRequest : RequestBase<ScrollRequestParameters>, IScrollRequest
40013997
{
40023998
protected IScrollRequest Self => this;
4003-
/// <summary>/_search/scroll</summary>
4004-
public ScrollRequest() : base(){}
4005-
4006-
4007-
///<summary>The URL-encoded request definition</summary>
3999+
///<summary>The URL-encoded request definition</summary>
40084000
public string Source { get { return Q<string>("source"); } set { Q("source", value); } }
40094001

40104002
///<summary>Comma separated list of filters used to reduce the response returned by Elasticsearch</summary>

0 commit comments

Comments
 (0)