diff --git a/CHANGELOG.md b/CHANGELOG.md index 25e29c1d..7f5835f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Removed the code that changed the first character of the query parameter name to lower case - Added sanitization of guid values in query parameters ## [1.3.2] - 2023-09-21 diff --git a/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs b/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs index 30108f04..be4cd9d8 100644 --- a/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs +++ b/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs @@ -111,6 +111,26 @@ public void DoesNotSetEmptyCollectionQueryParameters() Assert.False(requestInfo.QueryParameters.ContainsKey("select")); } [Fact] + public void DoesNotSetQueryParametersToLowerCaseFirstCharacter() + { + // Arrange as the request builders would + var requestInfo = new RequestInformation + { + HttpMethod = Method.GET, + UrlTemplate = "http://localhost/me{?%TenantId}" + }; + Action q = x => x.TenantId = "Tenant1"; + var qParams = new GetQueryParameters(); + q.Invoke(qParams); + + // Act + requestInfo.AddQueryParameters(qParams); + + // Assert + Assert.Contains("TenantId", requestInfo.QueryParameters.Keys); + Assert.DoesNotContain("tenantId", requestInfo.QueryParameters.Keys); + } + [Fact] public void SetsPathParametersOfDateTimeOffsetType() { // Arrange as the request builders would @@ -406,5 +426,7 @@ internal class GetQueryParameters /// Search items by search phrases [QueryParameter("%24search")] public string Search { get; set; } + /// Restrict to TenantId + public string TenantId { get; set; } } } diff --git a/src/RequestInformation.cs b/src/RequestInformation.cs index 341cbf83..b9485a91 100644 --- a/src/RequestInformation.cs +++ b/src/RequestInformation.cs @@ -110,7 +110,7 @@ public void AddQueryParameters(object source) x => ( Name: x.GetCustomAttributes(false) .OfType() - .FirstOrDefault()?.TemplateName ?? x.Name.ToFirstCharacterLowerCase(), + .FirstOrDefault()?.TemplateName ?? x.Name, Value: x.GetValue(source) ) )