Skip to content

Commit 9cab217

Browse files
committed
Build fixes post code gen update to ES master
1 parent fee93e3 commit 9cab217

File tree

22 files changed

+245
-506
lines changed

22 files changed

+245
-506
lines changed

src/CodeGeneration/CodeGeneration.LowLevelClient/ApiEndpoints/root.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# object: http://ogp.me/ns/object# article: http://ogp.me/ns/article# profile: http://ogp.me/ns/profile#">
88
<meta charset='utf-8'>
99

10-
<link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/frameworks-fd1030886ebf302bb352efb305c57a0ae0cbaa6bd33cd093b6e76eb5c61bed29.css" media="all" rel="stylesheet" />
11-
<link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/github-6382905c3b66add5f4c47d7fa403ac22b73cde4662b5ef81024c5e56298be41f.css" media="all" rel="stylesheet" />
10+
<link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/frameworks-0634787468a7fb65871b1f982175a82a3e3b2da5f6025de9b35e26433f9c0bb4.css" media="all" rel="stylesheet" />
11+
<link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/github-4d5a49248c6b116b386a57fdcff323d7e30583ddb73d85316553f903a3e960ae.css" media="all" rel="stylesheet" />
1212

1313

1414

1515
<link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/site-761fae5b692f533e1cb81ffa93667979373ec8f3d051c871fd56efe92d49825b.css" media="all" rel="stylesheet" />
1616

1717
<link as="script" href="https://assets-cdn.github.com/assets/frameworks-1fdd144c4b02024b03654934bcd7eb308f34bcdd374d6579a984c850d69dfd08.js" rel="preload" />
18-
<link as="script" href="https://assets-cdn.github.com/assets/github-bac94d428d8433c18cd8a40ad6f352f6c8b4a18ea07c492a40003d7785a240ef.js" rel="preload" />
18+
<link as="script" href="https://assets-cdn.github.com/assets/github-f961a7d2014469365d0464ba37b9ac0d26fae20f6c47813034024e71cce7bdc6.js" rel="preload" />
1919

2020
<meta http-equiv="X-UA-Compatible" content="IE=edge">
2121
<meta http-equiv="Content-Language" content="en">
@@ -54,7 +54,7 @@
5454
<meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA">
5555
<meta name="google-analytics" content="UA-3769691-2">
5656

57-
<meta content="collector.githubapp.com" name="octolytics-host" /><meta content="github" name="octolytics-app-id" /><meta content="6423A20A:6808:1B134DD:56E8541F" name="octolytics-dimension-request_id" />
57+
<meta content="collector.githubapp.com" name="octolytics-host" /><meta content="github" name="octolytics-app-id" /><meta content="6423A20A:680B:2C067C0:56E88DB6" name="octolytics-dimension-request_id" />
5858
<meta content="/&lt;user-name&gt;/&lt;repo-name&gt;/files/disambiguate" data-pjax-transient="true" name="analytics-location" />
5959

6060

@@ -67,14 +67,14 @@
6767
<meta name="user-login" content="">
6868

6969
<meta name="expected-hostname" content="github.com">
70-
<meta name="js-proxy-site-detection-payload" content="OTcyZWRkNmU4YjU5YmY2MTg0MjVmNmExNTlkYWE1ZGRhMjQ0YThiNWZhNGFlNWExNDg2OWFhY2U4NWRkNGEzZXx7InJlbW90ZV9hZGRyZXNzIjoiMTAwLjM1LjE2Mi4xMCIsInJlcXVlc3RfaWQiOiI2NDIzQTIwQTo2ODA4OjFCMTM0REQ6NTZFODU0MUYifQ==">
70+
<meta name="js-proxy-site-detection-payload" content="ZDIxN2E1MjI0OWUzNGQ0MTgwY2ExNWU5MjUwYjkzN2MzOTAyN2Q1OWY4NGUxZDMxZDBhMzZjM2U1MGQ0NTkzN3x7InJlbW90ZV9hZGRyZXNzIjoiMTAwLjM1LjE2Mi4xMCIsInJlcXVlc3RfaWQiOiI2NDIzQTIwQTo2ODBCOjJDMDY3QzA6NTZFODhEQjYifQ==">
7171

7272
<link rel="mask-icon" href="https://assets-cdn.github.com/pinned-octocat.svg" color="#4078c0">
7373
<link rel="icon" type="image/x-icon" href="https://assets-cdn.github.com/favicon.ico">
7474

75-
<meta content="f8dd6e65bae937376f902c96752e40b55f350591" name="form-nonce" />
75+
<meta content="776b81295fcaff27741bbf0ef9e0eefea5d76a1b" name="form-nonce" />
7676

77-
<meta http-equiv="x-pjax-version" content="a9b6cb9d8ccb4ca168a449919710e26a">
77+
<meta http-equiv="x-pjax-version" content="e79c883da22db5075f9776b15f9ab58c">
7878

7979

8080

@@ -227,15 +227,15 @@ <h1 class="entry-title public ">
227227
<a href="/elastic/elasticsearch/issues" class="js-selected-navigation-item reponav-item" data-hotkey="g i" data-selected-links="repo_issues repo_labels repo_milestones /elastic/elasticsearch/issues" itemprop="url">
228228
<svg aria-hidden="true" class="octicon octicon-issue-opened" height="16" role="img" version="1.1" viewBox="0 0 14 16" width="14"><path d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7S10.14 13.7 7 13.7 1.3 11.14 1.3 8s2.56-5.7 5.7-5.7m0-1.3C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7S10.86 1 7 1z m1 3H6v5h2V4z m0 6H6v2h2V10z"></path></svg>
229229
<span itemprop="name">Issues</span>
230-
<span class="counter">936</span>
230+
<span class="counter">937</span>
231231
<meta itemprop="position" content="2">
232232
</a> </span>
233233

234234
<span itemscope itemtype="http://schema.org/ListItem" itemprop="itemListElement">
235235
<a href="/elastic/elasticsearch/pulls" class="js-selected-navigation-item reponav-item" data-hotkey="g p" data-selected-links="repo_pulls /elastic/elasticsearch/pulls" itemprop="url">
236236
<svg aria-hidden="true" class="octicon octicon-git-pull-request" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path d="M11 11.28c0-1.73 0-6.28 0-6.28-0.03-0.78-0.34-1.47-0.94-2.06s-1.28-0.91-2.06-0.94c0 0-1.02 0-1 0V0L4 3l3 3V4h1c0.27 0.02 0.48 0.11 0.69 0.31s0.3 0.42 0.31 0.69v6.28c-0.59 0.34-1 0.98-1 1.72 0 1.11 0.89 2 2 2s2-0.89 2-2c0-0.73-0.41-1.38-1-1.72z m-1 2.92c-0.66 0-1.2-0.55-1.2-1.2s0.55-1.2 1.2-1.2 1.2 0.55 1.2 1.2-0.55 1.2-1.2 1.2zM4 3c0-1.11-0.89-2-2-2S0 1.89 0 3c0 0.73 0.41 1.38 1 1.72 0 1.55 0 5.56 0 6.56-0.59 0.34-1 0.98-1 1.72 0 1.11 0.89 2 2 2s2-0.89 2-2c0-0.73-0.41-1.38-1-1.72V4.72c0.59-0.34 1-0.98 1-1.72z m-0.8 10c0 0.66-0.55 1.2-1.2 1.2s-1.2-0.55-1.2-1.2 0.55-1.2 1.2-1.2 1.2 0.55 1.2 1.2z m-1.2-8.8c-0.66 0-1.2-0.55-1.2-1.2s0.55-1.2 1.2-1.2 1.2 0.55 1.2 1.2-0.55 1.2-1.2 1.2z"></path></svg>
237237
<span itemprop="name">Pull requests</span>
238-
<span class="counter">110</span>
238+
<span class="counter">113</span>
239239
<meta itemprop="position" content="3">
240240
</a> </span>
241241

@@ -4248,7 +4248,7 @@ <h1 class="entry-title public ">
42484248
<svg aria-hidden="true" class="octicon octicon-mark-github" height="24" role="img" title="GitHub " version="1.1" viewBox="0 0 16 16" width="24"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59 0.4 0.07 0.55-0.17 0.55-0.38 0-0.19-0.01-0.82-0.01-1.49-2.01 0.37-2.53-0.49-2.69-0.94-0.09-0.23-0.48-0.94-0.82-1.13-0.28-0.15-0.68-0.52-0.01-0.53 0.63-0.01 1.08 0.58 1.23 0.82 0.72 1.21 1.87 0.87 2.33 0.66 0.07-0.52 0.28-0.87 0.51-1.07-1.78-0.2-3.64-0.89-3.64-3.95 0-0.87 0.31-1.59 0.82-2.15-0.08-0.2-0.36-1.02 0.08-2.12 0 0 0.67-0.21 2.2 0.82 0.64-0.18 1.32-0.27 2-0.27 0.68 0 1.36 0.09 2 0.27 1.53-1.04 2.2-0.82 2.2-0.82 0.44 1.1 0.16 1.92 0.08 2.12 0.51 0.56 0.82 1.27 0.82 2.15 0 3.07-1.87 3.75-3.65 3.95 0.29 0.25 0.54 0.73 0.54 1.48 0 1.07-0.01 1.93-0.01 2.2 0 0.21 0.15 0.46 0.55 0.38C13.71 14.53 16 11.53 16 8 16 3.58 12.42 0 8 0z"></path></svg>
42494249
</a>
42504250
<ul class="site-footer-links">
4251-
<li>&copy; 2016 <span title="0.18725s from github-fe144-cp1-prd.iad.github.net">GitHub</span>, Inc.</li>
4251+
<li>&copy; 2016 <span title="0.12597s from github-fe139-cp1-prd.iad.github.net">GitHub</span>, Inc.</li>
42524252
<li><a href="https://github.com/site/terms" data-ga-click="Footer, go to terms, text:terms">Terms</a></li>
42534253
<li><a href="https://github.com/site/privacy" data-ga-click="Footer, go to privacy, text:privacy">Privacy</a></li>
42544254
<li><a href="https://github.com/security" data-ga-click="Footer, go to security, text:security">Security</a></li>
@@ -4275,7 +4275,7 @@ <h1 class="entry-title public ">
42754275

42764276
<script crossorigin="anonymous" src="https://assets-cdn.github.com/assets/compat-7db58f8b7b91111107fac755dd8b178fe7db0f209ced51fc339c446ad3f8da2b.js"></script>
42774277
<script crossorigin="anonymous" src="https://assets-cdn.github.com/assets/frameworks-1fdd144c4b02024b03654934bcd7eb308f34bcdd374d6579a984c850d69dfd08.js"></script>
4278-
<script async="async" crossorigin="anonymous" src="https://assets-cdn.github.com/assets/github-bac94d428d8433c18cd8a40ad6f352f6c8b4a18ea07c492a40003d7785a240ef.js"></script>
4278+
<script async="async" crossorigin="anonymous" src="https://assets-cdn.github.com/assets/github-f961a7d2014469365d0464ba37b9ac0d26fae20f6c47813034024e71cce7bdc6.js"></script>
42794279

42804280

42814281

src/CodeGeneration/CodeGeneration.LowLevelClient/ApiGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static ApiGenerator()
6161
public static string PascalCase(string s)
6262
{
6363
var textInfo = new CultureInfo("en-US").TextInfo;
64-
return textInfo.ToTitleCase(s.ToLowerInvariant()).Replace("_", string.Empty).Replace(".", string.Empty);
64+
return textInfo.ToTitleCase(s.ToLowerInvariant()).Replace("_", string.Empty).Replace(".", string.Empty).Replace("-", string.Empty);
6565
}
6666

6767
public void GenerateEndpointFiles()

src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/ApiEndpoint.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public string OptionallyAppendHttpMethod(IEnumerable<string> availableMethods, s
8181
//if on operation has two endpoints and one of them is GET always favor the other as default
8282
return currentHttpMethod == "GET" ? "Get" : string.Empty;
8383
}
84-
84+
8585
return availableMethods.First() == currentHttpMethod ? string.Empty : this.PascalCase(currentHttpMethod);
8686
}
8787

@@ -117,6 +117,9 @@ public IEnumerable<CsharpMethod> CsharpMethods
117117
return "string " + p.Name;
118118
case "enum":
119119
return this.PascalCase(p.Name) + p.Name;
120+
case "number":
121+
// TODO should we support long or some numeric type here?
122+
return "string " + p.Name;
120123
default:
121124
return p.Type + " " + p.Name;
122125
//return "string " + p.Name;
@@ -153,7 +156,7 @@ public IEnumerable<CsharpMethod> CsharpMethods
153156
ReturnType = "ElasticsearchResponse<T>",
154157
ReturnTypeGeneric = "<T>",
155158
CallTypeGeneric = "T",
156-
ReturnDescription =
159+
ReturnDescription =
157160
"ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:"
158161
+ explanationOfT,
159162
FullName = methodName,
@@ -165,8 +168,8 @@ public IEnumerable<CsharpMethod> CsharpMethods
165168
};
166169
Generator.PatchMethod(apiMethod);
167170

168-
args = args.Concat(new[]
169-
{
171+
args = args.Concat(new[]
172+
{
170173
"Func<"+apiMethod.QueryStringParamName+", " + apiMethod.QueryStringParamName + "> requestParameters = null"
171174
}).ToList();
172175
apiMethod.Arguments = string.Join(", ", args);
@@ -178,7 +181,7 @@ public IEnumerable<CsharpMethod> CsharpMethods
178181
ReturnType = "Task<ElasticsearchResponse<T>>",
179182
ReturnTypeGeneric = "<T>",
180183
CallTypeGeneric = "T",
181-
ReturnDescription =
184+
ReturnDescription =
182185
"A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:"
183186
+ explanationOfT,
184187
FullName = methodName + "Async",
@@ -191,15 +194,15 @@ public IEnumerable<CsharpMethod> CsharpMethods
191194
};
192195
Generator.PatchMethod(apiMethod);
193196
yield return apiMethod;
194-
197+
195198
//No need for deserialization state when returning dynamicdictionary
196199

197200
var explanationOfDynamic =
198-
paraIndent +
201+
paraIndent +
199202
"<para> - Dynamic dictionary is a special dynamic type that allows json to be traversed safely </para>"
200-
+ paraIndent +
203+
+ paraIndent +
201204
"<para> - i.e result.Response.hits.hits[0].property.nested[\"nested_deeper\"] </para>"
202-
+ paraIndent +
205+
+ paraIndent +
203206
"<para> - can be safely dispatched to a nullable type even if intermediate properties do not exist </para>";
204207

205208
var defaultBoundGeneric = Url.Path.Contains("_cat") ? "string" : "DynamicDictionary";
@@ -211,7 +214,7 @@ public IEnumerable<CsharpMethod> CsharpMethods
211214
ReturnTypeGeneric = null,
212215
//CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary" ? "Dictionary<string, object>" : defaultBoundGeneric,
213216
CallTypeGeneric = defaultBoundGeneric,
214-
ReturnDescription =
217+
ReturnDescription =
215218
"ElasticsearchResponse&lt;DynamicDictionary&gt;"
216219
+ explanationOfDynamic,
217220
FullName = methodName,
@@ -224,15 +227,15 @@ public IEnumerable<CsharpMethod> CsharpMethods
224227
};
225228
Generator.PatchMethod(apiMethod);
226229
yield return apiMethod;
227-
230+
228231
apiMethod = new CsharpMethod
229232
{
230233
QueryStringParamName = queryStringParamName,
231234
ReturnType = $"Task<ElasticsearchResponse<{defaultBoundGeneric}>>",
232235
ReturnTypeGeneric = null,
233236
//CallTypeGeneric = defaultBoundGeneric == "DynamicDictionary" ? "Dictionary<string, object>" : defaultBoundGeneric,
234237
CallTypeGeneric = defaultBoundGeneric,
235-
ReturnDescription =
238+
ReturnDescription =
236239
"A task of ElasticsearchResponse&lt;DynamicDictionary$gt;"
237240
+ explanationOfDynamic,
238241
FullName = methodName + "Async",
@@ -250,4 +253,4 @@ public IEnumerable<CsharpMethod> CsharpMethods
250253
}
251254
}
252255
}
253-
}
256+
}

src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/ApiQueryParameters.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ public string CsharpType(string paramName)
1919
return "bool";
2020
case "list":
2121
return "params string[]";
22+
case "integer":
23+
return "int";
2224
case "number":
23-
return new [] {"boost", "percen", "score"}.Any(s=>paramName.ToLowerInvariant().Contains(s))
24-
? "double"
25+
return new [] {"boost", "percen", "score"}.Any(s=>paramName.ToLowerInvariant().Contains(s))
26+
? "double"
2527
: "long";
2628
case "duration":
2729
case "time":
@@ -36,7 +38,7 @@ public string CsharpType(string paramName)
3638
return this.Type;
3739
}
3840
}
39-
41+
4042
public string HighLevelType(string paramName)
4143
{
4244
var csharpType = this.CsharpType(paramName);
@@ -49,4 +51,4 @@ public string HighLevelType(string paramName)
4951
}
5052
}
5153
}
52-
}
54+
}

src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/ApiUrlPart.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public string ClrTypeName
2121
case "id": return this.Type == "string" ? "Id" : "Ids";
2222
case "node_id": return this.Type == "string" ? "NodeId" : "NodeIds";
2323
case "scroll_id": return this.Type == "string" ? "ScrollId" : "ScrollIds";
24-
case "field":
24+
case "field":
2525
case "fields": return this.Type == "string" ? "Field" : "Fields";
2626
case "index_metric": return "IndexMetrics";
2727
case "metric": return "Metrics";
@@ -30,6 +30,7 @@ public string ClrTypeName
3030
case "snapshot":
3131
case "lang":
3232
case "name": return this.Type == "string" ? "Name" : "Names";
33+
case "task_id": return "TaskId";
3334
default: return this.Type + "_";
3435
}
3536
}
@@ -47,4 +48,4 @@ public string InterfaceName
4748
}
4849
}
4950
}
50-
}
51+
}

src/CodeGeneration/CodeGeneration.LowLevelClient/Views/ElasticLowLevelClient.Generated.cshtml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ namespace Elasticsearch.Net
3434
{
3535
var url = method.Path.Split(new[] {'/'}, 2).Last();
3636
int i = -1;
37-
var patchedUrl = Regex.Replace(url, @"{(\w+)}", "{$1.NotNull(\"$1\")}");
37+
var patchedUrl = url;
38+
if (!url.Contains("{task_id}"))
39+
{
40+
patchedUrl = Regex.Replace(url, @"{(\w+)}", "{$1.NotNull(\"$1\")}");
41+
}
3842
bool isAsync = method.ReturnType.StartsWith("Task<");
3943
string requestMethod = isAsync ? "DoRequestAsync" : "DoRequest";
4044
<text>///<summary>Represents a @method.HttpMethod on @method.Path

0 commit comments

Comments
 (0)