Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…s-dotnet into timanndella/issue128

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
timandella committed Sep 24, 2023
2 parents b88f654 + e02c9e5 commit 8fae1dc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions Microsoft.Kiota.Abstractions.Tests/RequestInformationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GetQueryParameters> 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
Expand Down Expand Up @@ -406,5 +426,7 @@ internal class GetQueryParameters
/// <summary>Search items by search phrases</summary>
[QueryParameter("%24search")]
public string Search { get; set; }
/// <summary>Restrict to TenantId</summary>
public string TenantId { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/RequestInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void AddQueryParameters(object source)
x => (
Name: x.GetCustomAttributes(false)
.OfType<QueryParameterAttribute>()
.FirstOrDefault()?.TemplateName ?? x.Name.ToFirstCharacterLowerCase(),
.FirstOrDefault()?.TemplateName ?? x.Name,
Value: x.GetValue(source)
)
)
Expand Down

0 comments on commit 8fae1dc

Please sign in to comment.