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: 1 addition & 1 deletion src/ApiGenerator/ApiGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageReference Include="CsQuery.Core" Version="2.0.1" />
<!-- https://github.com/toddams/RazorLight/issues/172 -->
<PackageReference Include="RazorLight.Unofficial" Version="2.0.0-beta1.3" />
<PackageReference Include="Spectre.Console" Version="0.27.1-preview.0.8" />
<PackageReference Include="Spectre.Console" Version="0.30.0" />
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.3.0-alpha.20371.2" />
<!--<PackageReference Include="RazorLight" Version="2.0.0-beta1" />-->
</ItemGroup>
Expand Down
24 changes: 22 additions & 2 deletions src/ApiGenerator/Domain/Specification/UrlInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
Expand Down Expand Up @@ -50,7 +51,7 @@ public IReadOnlyCollection<UrlPath> PathsWithDeprecations
// PUT /{index}/_mapping/{type}
// PUT /{index}/{type}/_mappings
//
//The following routine dedups these occasions and prefers either the cononical path
//The following routine dedups these occasions and prefers either the canonical path
//or the first duplicate deprecated path

var canonicalPartNameLookup = paths.Select(path => new HashSet<string>(path.Parts.Select(p => p.Name))).ToList();
Expand All @@ -64,10 +65,29 @@ public IReadOnlyCollection<UrlPath> PathsWithDeprecations
.Where(grouped => !canonicalPartNameLookup.Any(set => set.SetEquals(grouped.Key)))
.Select(grouped => grouped.First().deprecatedPath);


_pathsWithDeprecation = paths
.Concat(withoutDeprecatedAliases.Select(p => new UrlPath(p, OriginalParts, Paths)))
.ToList();

// now, check for and prefer deprecated URLs

var finalPathsWithDeprecations = new List<UrlPath>(_pathsWithDeprecation.Count);

foreach (var path in _pathsWithDeprecation)
{
if (path.Deprecation is null &&
DeprecatedPaths.SingleOrDefault(p => p.Path.Equals(path.Path, StringComparison.OrdinalIgnoreCase)) is { } match)
{
finalPathsWithDeprecations.Add(new UrlPath(match, OriginalParts, Paths));
}
else
{
finalPathsWithDeprecations.Add(path);
}
}

_pathsWithDeprecation = finalPathsWithDeprecations;

return _pathsWithDeprecation;
}
}
Expand Down
8 changes: 1 addition & 7 deletions src/ApiGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
// See the LICENSE file in the project root for more information

using System;
using System.CommandLine;
using System.CommandLine.DragonFruit;
using System.CommandLine.Invocation;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -21,8 +17,6 @@ public static class Program
{
private static bool Interactive { get; set; } = false;

public static Style HeaderStyle { get; } = new Style(Color.White, Color.Chartreuse4);

/// <summary>
/// A main function can also take <see cref="CancellationToken"/> which is hooked up to support termination (e.g CTRL+C)
/// </summary>
Expand Down Expand Up @@ -99,7 +93,7 @@ private static async Task<int> Generate(bool download, string branch, bool inclu
Console.WriteLine();
AnsiConsole.Render(
new Panel(grid)
.Header(new PanelHeader(" Elasticsearch .NET client API generator ", HeaderStyle, Justify.Left))
.Header(new PanelHeader("[b white on chartreuse4] Elasticsearch .NET client API generator [/]", Justify.Left))
);
Console.WriteLine();

Expand Down