Skip to content

Commit

Permalink
Re-generate snapshot namespace (opensearch-project#351)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <tsfarr@amazon.com>
  • Loading branch information
Xtansia committed Dec 3, 2023
1 parent 941a649 commit a977319
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/ApiGenerator/Configuration/CodeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static class CodeConfiguration
// e.g. new Glob("nodes.*"),
new("dangling_indices.*"),
new("ingest.*"),
new("snapshot.*"),
new("tasks.*")
};

Expand Down
17 changes: 7 additions & 10 deletions src/ApiGenerator/Domain/Specification/ApiEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,14 @@ public class ApiEndpoint
HttpMethod = PreferredHttpMethod
};

public string PreferredHttpMethod
{
get
public string PreferredHttpMethod =>
HttpMethods.OrderByDescending(m => m switch
{
var first = HttpMethods.First();
if (HttpMethods.Count > 1 && first.ToUpperInvariant() == "GET")
return HttpMethods.Last();

return first;
}
}
"GET" => 0,
"POST" => 1,
"PUT" or "DELETE" or "PATCH" or "HEAD" => 2, // Prefer "resource" methods over GET/POST methods
_ => -1
}).First();

public string HighLevelMethodXmlDocDescription =>
$"<c>{PreferredHttpMethod}</c> request to the <c>{Name}</c> API, read more about this API online:";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class HighLevelClientImplementationGenerator : RazorGeneratorBase
public override async Task Generate(RestApiSpec spec, ProgressBar progressBar, CancellationToken token)
{
var view = ViewLocations.HighLevel("Client", "Implementation", "OpenSearchClient.cshtml");
var target = GeneratorLocations.HighLevel($"OpenSearchClient.{CsharpNames.RootNamespace}.cs");
var target = GeneratorLocations.HighLevel($"OpenSearchClient.cs");
await DoRazor(spec, view, target, token);

string Target(string id) => GeneratorLocations.HighLevel($"OpenSearchClient.{id}.cs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class LowLevelClientImplementationGenerator : RazorGeneratorBase
public override async Task Generate(RestApiSpec spec, ProgressBar progressBar, CancellationToken token)
{
var view = ViewLocations.LowLevel("Client", "Implementation", "OpenSearchLowLevelClient.cshtml");
var target = GeneratorLocations.LowLevel($"OpenSearchLowLevelClient.{CsharpNames.RootNamespace}.cs");
var target = GeneratorLocations.LowLevel("OpenSearchLowLevelClient.cs");
await DoRazor(spec, view, target, token);

var namespaced = spec.EndpointsPerNamespaceLowLevel.Where(kv => kv.Key != CsharpNames.RootNamespace).ToList();
Expand Down

0 comments on commit a977319

Please sign in to comment.