Skip to content

Commit

Permalink
Fix: Escape paths containing the keyword "item"
Browse files Browse the repository at this point in the history
Fixes #4814
  • Loading branch information
CasperWSchmidt committed Jun 27, 2024
1 parent 81c351e commit 5105257
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static partial class OpenApiUrlTreeNodeExtensions
{
private static string GetDotIfBothNotNullOfEmpty(string x, string y) => string.IsNullOrEmpty(x) || string.IsNullOrEmpty(y) ? string.Empty : ".";
private static readonly Func<string, string> replaceSingleParameterSegmentByItem =
static x => x.IsPathSegmentWithSingleSimpleParameter() ? "item" : x;
static x => x.IsPathSegmentWithSingleSimpleParameter() ? "item" : ("item".Equals(x, StringComparison.OrdinalIgnoreCase) ? "item_escaped" : x);
private static readonly char[] namespaceNameSplitCharacters = ['.', '-', '$']; //$ref from OData
private const string EscapedSuffix = "Escaped";
internal static string GetNamespaceFromPath(this string currentPath, string prefix) =>
Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/KiotaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ private void CreateRequestBuilderClass(CodeNamespace currentNamespace, OpenApiUr
var className = currentNode.DoesNodeBelongToItemSubnamespace() ? currentNode.GetNavigationPropertyName(config.StructuredMimeTypes, ItemRequestBuilderSuffix) : currentNode.GetNavigationPropertyName(config.StructuredMimeTypes, RequestBuilderSuffix);
codeClass = targetNS.AddClass(new CodeClass
{
Name = className.CleanupSymbolName(),
Name = currentNamespace.Name.EndsWith("item_escaped", StringComparison.InvariantCultureIgnoreCase) ? className.CleanupSymbolName().Replace("item", "item_escaped", StringComparison.InvariantCultureIgnoreCase) : className.CleanupSymbolName(),
Kind = CodeClassKind.RequestBuilder,
Documentation = new()
{
Expand Down

0 comments on commit 5105257

Please sign in to comment.