Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8e0a27e

Browse files
github-actions[bot]stevejgordon
andauthored
Basic URL skipping (#5851) (#5853)
Co-authored-by: Steve Gordon <sgordon@hotmail.co.uk>
1 parent 890c4cb commit 8e0a27e

File tree

4 files changed

+31
-17
lines changed

4 files changed

+31
-17
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information
4+
5+
using System.Collections.Generic;
6+
7+
namespace ApiGenerator.Configuration
8+
{
9+
public static class GeneralSkipList
10+
{
11+
public static IReadOnlyCollection<string> SkippedUrls => new[] { "/_search/scroll/{scroll_id}" };
12+
}
13+
}

‎src/ApiGenerator/Domain/Code/HighLevel/Requests/Constructor.cs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ string generic
4747
{
4848
var ctors = new List<Constructor>();
4949

50-
// Include deprecated paths to ensure these are not removed (a breaking change) during 7.x releases.
51-
// For historical reasons, constructors for deprecated paths which specified a type where removed in 7.0 and
52-
// therefore we don't include those in generation to avoid them being re-added.
53-
var paths = url.Paths.ToList().Union(url.PathsWithDeprecations.Where(x => x.Parts.All(p => p.Name != "type")));
50+
var paths = url.FinalPaths;
5451

5552
if (url.IsPartless) return ctors;
5653

@@ -100,13 +97,15 @@ string generic
10097
}
10198
var constructors = ctors.GroupBy(c => c.Generated.Split(new[] { ':' }, 2)[0]).Select(g => g.Last()).ToList();
10299
if (!constructors.Any(c => c.Parameterless))
100+
{
103101
constructors.Add(new Constructor
104102
{
105103
Parameterless = true,
106104
Generated = $"protected {typeName}() : base()",
107105
Description =
108106
$"///<summary>Used for serialization purposes, making sure we have a parameterless constructor</summary>{Indent}[SerializationConstructor]",
109107
});
108+
}
110109
return constructors;
111110
}
112111
}

‎src/ApiGenerator/Domain/Specification/ApiEndpoint.cs‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class ApiEndpoint
2828
CsharpNames = CsharpNames,
2929
OfficialDocumentationLink = OfficialDocumentationLink?.Url,
3030
Constructors = Constructor.DescriptorConstructors(CsharpNames, Url).ToList(),
31-
Paths = Url.Paths.Union(Url.PathsWithDeprecations).ToArray(),
31+
Paths = Url.FinalPaths,
3232
Parts = Url.Parts,
3333
Params = Url.Params.Values.Where(p => !p.Skip).ToList(),
3434
HasBody = Body != null,
@@ -41,18 +41,18 @@ public class ApiEndpoint
4141
public string HighLevelMethodXmlDocDescription =>
4242
$"<c>{PreferredHttpMethod}</c> request to the <c>{Name}</c> API, read more about this API online:";
4343

44-
public HighLevelModel HighLevelModel => newHighLevelModel
44+
public HighLevelModel HighLevelModel => new()
4545
{
4646
CsharpNames = CsharpNames,
4747
Fluent = new FluentMethod(CsharpNames, Url.Parts,
48-
Body ==null||!Body.Required || HttpMethods.Contains("GET"),
48+
Body is not {Required:true} || HttpMethods.Contains("GET"),
4949
OfficialDocumentationLink?.Url,
5050
HighLevelMethodXmlDocDescription
5151
),
5252
FluentBound = !CsharpNames.DescriptorBindsOverMultipleDocuments
5353
? null
5454
: new BoundFluentMethod(CsharpNames, Url.Parts,
55-
Body ==null||!Body.Required || HttpMethods.Contains("GET"),
55+
Body is not {Required:true} || HttpMethods.Contains("GET"),
5656
OfficialDocumentationLink?.Url,
5757
HighLevelMethodXmlDocDescription
5858
),
@@ -168,11 +168,7 @@ public string PreferredHttpMethod
168168
CsharpNames = CsharpNames,
169169
OfficialDocumentationLink = OfficialDocumentationLink?.Url,
170170
Stability = Stability,
171-
// Paths are used to generate API URL lookups
172-
// Include deprecated paths to ensure these are not removed (a breaking change) during 7.x releases.
173-
// For historical reasons, constructors for deprecated paths which specified a type where removed in 7.0 and
174-
// therefore we don't include those in generation to avoid them being re-added.
175-
Paths = Url.Paths.Union(Url.PathsWithDeprecations).Where(x => x.Parts.All(p => p.Name != "type")).ToArray(),
171+
Paths = Url.FinalPaths,
176172
Parts = Url.Parts,
177173
Params = Url.Params.Values.Where(p => !p.Skip).ToList(),
178174
Constructors = Constructor.RequestConstructors(CsharpNames, Url, true).ToList(),

‎src/ApiGenerator/Domain/Specification/UrlInformation.cs‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Linq;
8+
using ApiGenerator.Configuration;
89
using Newtonsoft.Json;
910

1011
namespace ApiGenerator.Domain.Specification
@@ -18,6 +19,14 @@ public class UrlInformation
1819

1920
private List<UrlPath> _pathsWithDeprecation;
2021

22+
// Include deprecated paths to ensure these are not removed (a breaking change) during 7.x releases.
23+
// For historical reasons, constructors for deprecated paths which specified a type where removed in 7.0 and
24+
// therefore we don't include those in generation to avoid them being re-added.
25+
public IReadOnlyCollection<UrlPath> FinalPaths =>
26+
Paths.Union(PathsWithDeprecations.Where(x => x.Parts.All(p => p.Name != "type")))
27+
.Where(x => !GeneralSkipList.SkippedUrls.Contains(x.Path))
28+
.ToArray();
29+
2130
public bool IsDocumentApi => IsADocumentRoute(Parts);
2231

2332
public bool IsPartless => !Parts.Any();
@@ -27,10 +36,7 @@ public class UrlInformation
2736

2837
public IDictionary<string, QueryParameters> Params { get; set; } = new SortedDictionary<string, QueryParameters>();
2938

30-
// Include deprecated paths to ensure these are not removed (a breaking change) during 7.x releases.
31-
// For historical reasons, constructors for deprecated paths which specified a type where removed in 7.0 and
32-
// therefore we don't include those in generation to avoid them being re-added.
33-
public IReadOnlyCollection<UrlPart> Parts => Paths.Union(PathsWithDeprecations.Where(x => x.Parts.All(p => p.Name != "type")))
39+
public IReadOnlyCollection<UrlPart> Parts => FinalPaths
3440
.SelectMany(p => p.Parts)
3541
.DistinctBy(p => p.Name)
3642
.ToList();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /