Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 7.7] Fix API generator (#4456) #4517

Merged
merged 1 commit into from
Mar 27, 2020
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
4 changes: 2 additions & 2 deletions src/ApiGenerator/Domain/RestApiSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public class RestApiSpec

public IDictionary<string, ApiEndpoint> Endpoints { get; set; }

public ImmutableSortedDictionary<string, ReadOnlyCollection<ApiEndpoint>> EndpointsPerNamespace =>
public ImmutableSortedDictionary<string, ReadOnlyCollection<ApiEndpoint>> EndpointsPerNamespaceLowLevel =>
Endpoints.Values.GroupBy(e=>e.CsharpNames.Namespace)
.ToImmutableSortedDictionary(kv => kv.Key, kv => kv.ToList().AsReadOnly());

public ImmutableSortedDictionary<string, ReadOnlyCollection<ApiEndpoint>> EndpointsPerNamespaceHighLevel =>
Endpoints.Values
.Where(v => !CodeConfiguration.IgnoredApisHighLevel.Contains(v.Name))
.Where(v => !CodeConfiguration.IgnoredApisHighLevel.Contains(v.FileName))
.GroupBy(e => e.CsharpNames.Namespace)
.ToImmutableSortedDictionary(kv => kv.Key, kv => kv.ToList().AsReadOnly());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override async Task Generate(RestApiSpec spec, ProgressBar progressBar)
var target = GeneratorLocations.LowLevel($"ElasticLowLevelClient.{CsharpNames.RootNamespace}.cs");
await DoRazor(spec, view, target);

var namespaced = spec.EndpointsPerNamespaceHighLevel.Where(kv => kv.Key != CsharpNames.RootNamespace).ToList();
var namespaced = spec.EndpointsPerNamespaceLowLevel.Where(kv => kv.Key != CsharpNames.RootNamespace).ToList();
var namespacedView = ViewLocations.LowLevel("Client", "Implementation", "ElasticLowLevelClient.Namespace.cshtml");
await DoRazorDependantFiles(progressBar, namespaced, namespacedView, kv => kv.Key,
id => GeneratorLocations.LowLevel($"ElasticLowLevelClient.{id}.cs"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override async Task Generate(RestApiSpec spec, ProgressBar progressBar)
var view = ViewLocations.LowLevel("RequestParameters", "RequestParameters.cshtml");
string Target(string id) => GeneratorLocations.LowLevel("Api", "RequestParameters", $"RequestParameters.{id}.cs");

var namespaced = spec.EndpointsPerNamespaceHighLevel.ToList();
var namespaced = spec.EndpointsPerNamespaceLowLevel.ToList();
await DoRazorDependantFiles(progressBar, namespaced, view, kv => kv.Key, id => Target(id));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using static Elasticsearch.Net.HttpMethod;

@{
RestApiSpec model = Model;
var namespaces = model.EndpointsPerNamespace.Keys.Where(k => k != CsharpNames.RootNamespace);
var namespaces = model.EndpointsPerNamespaceLowLevel.Keys.Where(k => k != CsharpNames.RootNamespace);
<text>
// ReSharper disable InterpolatedStringExpressionIsNotIFormattable
// ReSharper disable RedundantExtendsListEntry
Expand Down Expand Up @@ -55,7 +55,7 @@ namespace Elasticsearch.Net
</text>


foreach (var kv in model.EndpointsPerNamespace)
foreach (var kv in model.EndpointsPerNamespaceLowLevel)
{
if (kv.Key != CsharpNames.RootNamespace)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Elasticsearch.Net
///</summary>
public partial interface IElasticLowLevelClient
{
@foreach(var kv in Model.EndpointsPerNamespace)
@foreach(var kv in Model.EndpointsPerNamespaceLowLevel)
{
if (kv.Key != CsharpNames.RootNamespace)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ApiGenerator/Views/LowLevel/Client/Usings.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@using ApiGenerator.Domain
@using ApiGenerator.Domain.Code
@inherits ApiGenerator.CodeTemplatePage<RestApiSpec>
@foreach(var kv in Model.EndpointsPerNamespace)
@foreach(var kv in Model.EndpointsPerNamespaceLowLevel)
{
if (kv.Key != CsharpNames.RootNamespace)
{
Expand Down