From 2f40d566f4aae97e3bf5bba50e34c48789672410 Mon Sep 17 00:00:00 2001 From: timandella Date: Sat, 23 Sep 2023 15:56:46 +0100 Subject: [PATCH 1/3] fix: issue 128 - Added sanitization for guid --- .../RequestInformationTests.cs | 25 +++++++++++++++++++ src/RequestInformation.cs | 1 + 2 files changed, 26 insertions(+) diff --git a/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs b/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs index 3d7f66a0..30108f04 100644 --- a/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs +++ b/Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs @@ -153,6 +153,28 @@ public void SetsPathParametersOfBooleanType() // Assert Assert.Contains("%24count=true", requestInfo.URI.OriginalString); } + [Fact] + public void SetsPathParametersOfGuidType() + { + // Arrange as the request builders would + var requestInfo = new RequestInformation + { + HttpMethod = Method.GET, + UrlTemplate = "http://localhost/users{?%24requestId}" + }; + + // Act + var guid = Guid.Parse("6d320a89-2d8f-4204-855d-b98a1bc176d4"); + var pathParameters = new Dictionary + { + { "%24requestId", guid } + }; + + requestInfo.PathParameters = pathParameters; + + // Assert + Assert.Contains($"%24requestId=6d320a89-2d8f-4204-855d-b98a1bc176d4", requestInfo.URI.OriginalString); + } [Fact] public void ThrowsInvalidOperationExceptionWhenBaseUrlNotSet() @@ -369,6 +391,9 @@ internal class GetQueryParameters /// Select properties to be returned\ [QueryParameter("%24select")] public string[] Select { get; set; } + /// Unique id of the request + [QueryParameter("%24requestId")] + public Guid RequestId { get; set; } /// Include count of items [QueryParameter("%24count")] public bool? Count { get; set; } diff --git a/src/RequestInformation.cs b/src/RequestInformation.cs index 8be72538..341cbf83 100644 --- a/src/RequestInformation.cs +++ b/src/RequestInformation.cs @@ -77,6 +77,7 @@ public Uri URI bool boolean => boolean.ToString().ToLower(),// pass in a lowercase string as the final url will be uppercase due to the way ToString() works for booleans DateTimeOffset dateTimeOffset => dateTimeOffset.ToString("o"),// Default to ISO 8601 for datetimeoffsets in the url. DateTime dateTime => dateTime.ToString("o"),// Default to ISO 8601 for datetimes in the url. + Guid guid => guid.ToString("D"),// Default of 32 digits separated by hyphens _ => value,//return object as is as the ToString method is good enough. }; From b88f654b727b758a9c294f2353c3c71eb6ba043a Mon Sep 17 00:00:00 2001 From: timandella Date: Sat, 23 Sep 2023 20:08:23 +0100 Subject: [PATCH 2/3] Added changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e241db1c..25e29c1d 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 + +- Added sanitization of guid values in query parameters + ## [1.3.2] - 2023-09-21 ### Changed From 7e3a5aa492964a4db9e4ae397b2626af4d065317 Mon Sep 17 00:00:00 2001 From: Andrew Omondi Date: Mon, 25 Sep 2023 09:00:27 +0300 Subject: [PATCH 3/3] Bumps version for release --- CHANGELOG.md | 2 ++ src/Microsoft.Kiota.Abstractions.csproj | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f5835f9..7e301bb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.3.3] - 2023-09-25 + ### Changed - Removed the code that changed the first character of the query parameter name to lower case diff --git a/src/Microsoft.Kiota.Abstractions.csproj b/src/Microsoft.Kiota.Abstractions.csproj index d45f2c34..17989e23 100644 --- a/src/Microsoft.Kiota.Abstractions.csproj +++ b/src/Microsoft.Kiota.Abstractions.csproj @@ -14,7 +14,7 @@ https://aka.ms/kiota/docs true true - 1.3.2 + 1.3.3 true false