Skip to content

Commit cd20a6a

Browse files
authored
Merge pull request #130 from timandella/timanndella/issue128
fix: issue 128 - Added sanitization for guid
2 parents e02c9e5 + 7e3a5aa commit cd20a6a

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.3.3] - 2023-09-25
11+
1012
### Changed
1113

1214
- Removed the code that changed the first character of the query parameter name to lower case
15+
- Added sanitization of guid values in query parameters
1316

1417
## [1.3.2] - 2023-09-21
1518

Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,28 @@ public void SetsPathParametersOfBooleanType()
173173
// Assert
174174
Assert.Contains("%24count=true", requestInfo.URI.OriginalString);
175175
}
176+
[Fact]
177+
public void SetsPathParametersOfGuidType()
178+
{
179+
// Arrange as the request builders would
180+
var requestInfo = new RequestInformation
181+
{
182+
HttpMethod = Method.GET,
183+
UrlTemplate = "http://localhost/users{?%24requestId}"
184+
};
185+
186+
// Act
187+
var guid = Guid.Parse("6d320a89-2d8f-4204-855d-b98a1bc176d4");
188+
var pathParameters = new Dictionary<string, object>
189+
{
190+
{ "%24requestId", guid }
191+
};
192+
193+
requestInfo.PathParameters = pathParameters;
194+
195+
// Assert
196+
Assert.Contains($"%24requestId=6d320a89-2d8f-4204-855d-b98a1bc176d4", requestInfo.URI.OriginalString);
197+
}
176198

177199
[Fact]
178200
public void ThrowsInvalidOperationExceptionWhenBaseUrlNotSet()
@@ -389,6 +411,9 @@ internal class GetQueryParameters
389411
/// <summary>Select properties to be returned</summary>\
390412
[QueryParameter("%24select")]
391413
public string[] Select { get; set; }
414+
/// <summary>Unique id of the request</summary>
415+
[QueryParameter("%24requestId")]
416+
public Guid RequestId { get; set; }
392417
/// <summary>Include count of items</summary>
393418
[QueryParameter("%24count")]
394419
public bool? Count { get; set; }

src/Microsoft.Kiota.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageProjectUrl>https://aka.ms/kiota/docs</PackageProjectUrl>
1515
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1616
<Deterministic>true</Deterministic>
17-
<VersionPrefix>1.3.2</VersionPrefix>
17+
<VersionPrefix>1.3.3</VersionPrefix>
1818
<VersionSuffix></VersionSuffix>
1919
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2020
<SignAssembly>false</SignAssembly>

src/RequestInformation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public Uri URI
7777
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
7878
DateTimeOffset dateTimeOffset => dateTimeOffset.ToString("o"),// Default to ISO 8601 for datetimeoffsets in the url.
7979
DateTime dateTime => dateTime.ToString("o"),// Default to ISO 8601 for datetimes in the url.
80+
Guid guid => guid.ToString("D"),// Default of 32 digits separated by hyphens
8081
_ => value,//return object as is as the ToString method is good enough.
8182
};
8283

0 commit comments

Comments
 (0)