- /// The pascal cased method name as loaded by
- /// Uses mapping of request implementations in the OSC code base
- ///
- public string MethodName { get; }
-
- public string ApiName { get; }
-
- public string RequestName => $"{ApiName}Request";
-
- public string ResponseName
- {
- get
- {
- if (Namespace == "Cat") return $"CatResponse<{ApiName}Record>";
- if (ApiName.EndsWith("Exists")) return "ExistsResponse";
-
- var generatedName = $"{ApiName}Response";
- return CodeConfiguration.ResponseLookup.TryGetValue(generatedName, out var lookup) ? lookup.Item1 : generatedName;
- }
- }
-
- public string RequestInterfaceName => $"I{RequestName}";
- public string ParametersName => $"{RequestName}Parameters";
- public string DescriptorName => $"{ApiName}Descriptor";
-
- public const string ApiNamespace = "Specification";
- public const string ApiNamespaceSuffix = "Api";
- public const string RootNamespace = "NoNamespace";
- public const string LowLevelClientNamespacePrefix = "LowLevel";
- public const string HighLevelClientNamespacePrefix = "";
- public const string ClientNamespaceSuffix = "Namespace";
-
- private static string CreateCSharpNamespace(string endpointNamespace)
- {
- switch (endpointNamespace)
- {
- case null:
- case "": return RootNamespace;
- default: return endpointNamespace.ToPascalCase();
- }
- }
-
- public string PerPathMethodName(string path)
- {
- var method = MethodName;
- // This is temporary for transition period
- // TODO: remove in branch once it in opensearch is scrubbed
- if (path.Contains("{type}") && !method.Contains("Type")) method += "UsingType";
-
- if (Namespace == null) return method;
-
- if (Namespace.StartsWith("Indices") && !path.Contains("{index}"))
- return (method + "ForAll").Replace("AsyncForAll", "ForAllAsync");
-
- if (Namespace.StartsWith("Nodes") && !path.Contains("{node_id}"))
- return (method + "ForAll").Replace("AsyncForAll", "ForAllAsync");
-
- return method;
- }
-
-
- public string GenericsDeclaredOnRequest =>
- CodeConfiguration.RequestInterfaceGenericsLookup.TryGetValue(RequestInterfaceName, out var requestGeneric) ? requestGeneric : null;
-
- public string GenericsDeclaredOnResponse =>
- CodeConfiguration.ResponseLookup.TryGetValue(ResponseName, out var requestGeneric) ? requestGeneric.Item2 : null;
-
- public string GenericsDeclaredOnDescriptor =>
- CodeConfiguration.DescriptorGenericsLookup.TryGetValue(DescriptorName, out var generic) ? generic : null;
-
- public IEnumerable