diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f6d7bfe89..03e9b65013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed handling of nested arrays to be handled as `UntypedNode` instances [#4549](https://github.com/microsoft/kiota/issues/4549) - Fixed `InvalidOperationException` thrown when serializing IBacked models with no changes present in the additional data in dotnet [microsoftgraph/msgraph-sdk-dotnet#2471](https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/2471). - Fixed `RequestConfiguration` Classes dropped in RequestBuilder methods in python [#4535](https://github.com/microsoft/kiota/issues/4535) +- Updated conversion to snake case to deal with strigns with multiple uppercase letters in a row for example "imageURL" will be converted to "image_url" and not "image_u_r_l" - Fixed incorrect optional types in method parameters in Python [#4507](https://github.com/microsoft/kiota/issues/4507) ## [1.14.0] - 2024-05-02 diff --git a/src/Kiota.Builder/Extensions/StringExtensions.cs b/src/Kiota.Builder/Extensions/StringExtensions.cs index d220b073f1..ab6a8a247c 100644 --- a/src/Kiota.Builder/Extensions/StringExtensions.cs +++ b/src/Kiota.Builder/Extensions/StringExtensions.cs @@ -82,7 +82,7 @@ static int CountNecessaryNewSeparators(ReadOnlySpan span) int count = 0; for (var i = 1; i < span.Length; i++) { - if (char.IsUpper(span[i]) && span[i - 1] is not '_' and not '-') + if (char.IsUpper(span[i]) && span[i - 1] is not '_' and not '-' && !char.IsUpper(span[i - 1])) { count++; } @@ -105,7 +105,10 @@ static int CountNecessaryNewSeparators(ReadOnlySpan span) } else if (char.IsUpper(current)) { - if (nameSpan[i - 1] != '_') span[counter++] = separator; + if (nameSpan[i - 1] is not '_' && !char.IsUpper(nameSpan[i - 1])) + { + span[counter++] = separator; + } span[counter++] = char.ToLowerInvariant(current); } else diff --git a/tests/Kiota.Builder.Tests/Extensions/StringExtensionsTests.cs b/tests/Kiota.Builder.Tests/Extensions/StringExtensionsTests.cs index 6e9fce63a3..917e8db88e 100644 --- a/tests/Kiota.Builder.Tests/Extensions/StringExtensionsTests.cs +++ b/tests/Kiota.Builder.Tests/Extensions/StringExtensionsTests.cs @@ -75,6 +75,8 @@ public void ToSnakeCase() Assert.Equal("microsoft_graph_message_content", "microsoft_Graph_Message_Content".ToSnakeCase()); Assert.Equal("test_value", "testValue