diff --git a/src/ApiGenerator/ApiGenerator.csproj b/src/ApiGenerator/ApiGenerator.csproj index a595ed00bb6..9d3eb5100b0 100644 --- a/src/ApiGenerator/ApiGenerator.csproj +++ b/src/ApiGenerator/ApiGenerator.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/ApiGenerator/Domain/Specification/UrlInformation.cs b/src/ApiGenerator/Domain/Specification/UrlInformation.cs index ee3fc07404a..fda5ce279ae 100644 --- a/src/ApiGenerator/Domain/Specification/UrlInformation.cs +++ b/src/ApiGenerator/Domain/Specification/UrlInformation.cs @@ -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; @@ -50,7 +51,7 @@ public IReadOnlyCollection 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(path.Parts.Select(p => p.Name))).ToList(); @@ -64,10 +65,29 @@ public IReadOnlyCollection 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(_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; } } diff --git a/src/ApiGenerator/Program.cs b/src/ApiGenerator/Program.cs index 3f0604915db..bc4b0a46eb9 100644 --- a/src/ApiGenerator/Program.cs +++ b/src/ApiGenerator/Program.cs @@ -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; @@ -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); - /// /// A main function can also take which is hooked up to support termination (e.g CTRL+C) /// @@ -99,7 +93,7 @@ private static async Task 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();