From 2bf72b7822e823290409f4958fadefc3ee13e26c Mon Sep 17 00:00:00 2001 From: timandella Date: Sat, 23 Sep 2023 15:22:11 +0100 Subject: [PATCH 1/2] fix: issue 127 - Do not set first character of query parameter name to lower case --- .../RequestInformationTests.cs | 22 +++++++++++++++++++ src/RequestInformation.cs | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs b/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs index 3d7f66a0..dedb0761 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 @@ -381,5 +401,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 8be72538..2540d78d 100644 --- a/src/RequestInformation.cs +++ b/src/RequestInformation.cs @@ -109,7 +109,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) ) ) From d8b1c39f49d99968aed69a5806798d5be1717083 Mon Sep 17 00:00:00 2001 From: timandella Date: Sat, 23 Sep 2023 20:05:14 +0100 Subject: [PATCH 2/2] Added changelog entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e241db1c..49d08ad1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Removed the code that changed the first character of the query parameter name to lower case + ## [1.3.2] - 2023-09-21 ### Changed