Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/CodeGeneration/ApiGenerator/Domain/ApiEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ private void PatchRequestParameters(IEndpointOverrides overrides)
if (globalOverrides.RenderPartial.Contains(newName))
kv.Value.RenderPartial = true;

//make sure source_enabled takes a boolean only
if (newName == "source_enabled") kv.Value.Type = "boolean";

patchedParams.Add(newName, kv.Value);
}
Expand Down
21 changes: 17 additions & 4 deletions src/CodeGeneration/ApiGenerator/Domain/ApiQueryParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public class ApiQueryParameters
public string Obsolete { get; set; }
public IEnumerable<string> Options { get; set; }



public string CsharpType(string paramName)
{
switch (this.Type)
Expand Down Expand Up @@ -56,6 +54,9 @@ public IEnumerable<string> HighLevelTypeDescription(string paramName)
yield return "<para>For requests that are constructed from/for a document NEST will automatically infer the routing key";
yield return "if that document has a <see cref=\"Nest.JoinField\" /> or a routing mapping on for its type exists on <see cref=\"Nest.ConnectionSettings\" /></para> ";
yield break;
case "source_enabled":
yield return "Whether the _source should be included in the response.";
yield break;
default:
yield return this.Description;
yield break;
Expand All @@ -80,13 +81,25 @@ public string HighLevelType(string paramName)
case "string" when isFields: return "Fields";
case "string" when o.Contains("field"): return "Field";
default:
return csharpType;
return NullableCsharpType(csharpType);
}
}
private static string NullableCsharpType(string fieldType)
{
switch (fieldType)
{
case "bool": return "bool?";
case "integer": return "int?";
case "double": return "double?";
case "long": return "long?";
default:
return fieldType;
}
}

public Func<string, string, string, string, string> Generator { get; set; } =
(fieldType, mm, original, setter) =>
$"public {fieldType} {mm} {{ get {{ return Q<{fieldType}>(\"{original}\"); }} set {{ Q(\"{original}\", {setter}); }} }}";
$"public {NullableCsharpType(fieldType)} {mm} {{ get {{ return Q<{NullableCsharpType(fieldType)}>(\"{original}\"); }} set {{ Q(\"{original}\", {setter}); }} }}";

public Func<string, string, string, string, string> FluentGenerator { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace Nest
}
var t = @kv.Value.HighLevelType(kv.Key);
var tMethod = t == "Time" ? ".ToTimeSpan()" : "";
var tSuffix = (t == "bool") ? " = true" : "";
var tSuffix = (t == "bool" || t == "bool?") ? " = true" : "";
var m = kv.Key.ToPascalCase();
var mm = (m != "Type" && m != "Index" && m != "Source" && m != "Script") ? m : m + "QueryString";
var typed = !method.DescriptorTypeGeneric.IsNullOrEmpty();
Expand Down
1,616 changes: 808 additions & 808 deletions src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs

Large diffs are not rendered by default.

1,636 changes: 818 additions & 818 deletions src/Nest/_Generated/_Descriptors.generated.cs

Large diffs are not rendered by default.

1,882 changes: 941 additions & 941 deletions src/Nest/_Generated/_Requests.generated.cs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/Tests/Search/Explain/ExplainApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected override LazyResponses ClientUsage() => Calls(

protected override ExplainDescriptor<Project> NewDescriptor() => new ExplainDescriptor<Project>(_project);

private Project _project = new Project { Name = Project.Instance.Name };
private readonly Project _project = new Project { Name = Project.Instance.Name };

protected override object ExpectJson => new
{
Expand All @@ -49,7 +49,7 @@ protected override LazyResponses ClientUsage() => Calls(
};

protected override Func<ExplainDescriptor<Project>, IExplainRequest<Project>> Fluent => e => e
.SourceEnabled("true") //TODO this should be generated as a bool
.SourceEnabled()
.Query(q => q
.Match(m => m
.Field(p => p.Name)
Expand All @@ -59,7 +59,7 @@ protected override LazyResponses ClientUsage() => Calls(

protected override ExplainRequest<Project> Initializer => new ExplainRequest<Project>(_project)
{
SourceEnabled = new [] { "true" },
SourceEnabled = true,
Query = new QueryContainer(new MatchQuery
{
Field = "name",
Expand Down