Skip to content

Commit

Permalink
Merge pull request #173 from microsoft/andrueastman/fixParameters
Browse files Browse the repository at this point in the history
Fixes missing parameter values on empty strings
  • Loading branch information
andrueastman authored Jan 11, 2024
2 parents a8aec2d + e6d2f2c commit 06b6d62
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.7.5] - 2024-01-11

### Changed

- Fixes missing query parameters when the parameter values are empty strings.(https://github.com/microsoft/kiota-abstractions-dotnet/issues/172)

## [1.7.4] - 2024-01-09

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ public void DoesNotSetEmptyStringQueryParameters()
requestInfo.AddQueryParameters(qParams);

// Assert
Assert.False(requestInfo.QueryParameters.ContainsKey($"%24search"));
Assert.True(requestInfo.QueryParameters.ContainsKey($"%24search"));
Assert.False(requestInfo.QueryParameters.ContainsKey("search"));
Assert.Equal("http://localhost/me?%24search=", requestInfo.URI.OriginalString);
}
[Fact]
public void DoesNotSetEmptyCollectionQueryParameters()
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Kiota.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageProjectUrl>https://aka.ms/kiota/docs</PackageProjectUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<Deterministic>true</Deterministic>
<VersionPrefix>1.7.4</VersionPrefix>
<VersionPrefix>1.7.5</VersionPrefix>
<VersionSuffix></VersionSuffix>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<SignAssembly>false</SignAssembly>
Expand Down
1 change: 0 additions & 1 deletion src/RequestInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ public void AddQueryParameters<T>(T source)
)
.Where(x => x.Value != null &&
!QueryParameters.ContainsKey(x.Name!) &&
!string.IsNullOrEmpty(x.Value.ToString()) && // no need to add an empty string value
(x.Value is not ICollection collection || collection.Count > 0))) // no need to add empty collection
{
QueryParameters.AddOrReplace(property.Name!, property.Value!);
Expand Down

0 comments on commit 06b6d62

Please sign in to comment.