Skip to content

Commit

Permalink
Revert "Omit null query parameters in generated http client (Breaks c…
Browse files Browse the repository at this point in the history
…ompatibility with ASP.NET WebApi because query arguments are part of the routing selection)"

This reverts commit caa74b8.
  • Loading branch information
C0nquistadore committed Jun 5, 2024
1 parent 08a5f1a commit 2199c99
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Dibix.Http.Client/Client/UriBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private UriBuilder(string url, UriKind kind)

public UriBuilder AddQueryParam<T>(string name, T value) where T : struct => this.AddQueryParam(name, ToString(value));
public UriBuilder AddQueryParam<T>(string name, T value, T defaultValue) where T : struct => !Equals(value, defaultValue) ? AddQueryParam(name, ToString(value)) : this;
public UriBuilder AddQueryParam<T>(string name, T? value) where T : struct => value != null ? AddQueryParam(name, ToString(value)) : this;
public UriBuilder AddQueryParam<T>(string name, T? value) where T : struct => this.AddQueryParam(name, ToString(value));
public UriBuilder AddQueryParam<T>(string name, T? value, T? defaultValue) where T : struct => !Equals(value, defaultValue) ? AddQueryParam(name, ToString(value)) : this;
public UriBuilder AddQueryParam(string name, string value, string defaultValue) => !Equals(value, defaultValue) ? AddQueryParam(name, ToString(value)) : this;
public UriBuilder AddQueryParam(string name, string value)
Expand Down
3 changes: 1 addition & 2 deletions tests/Dibix.Http.Client.Tests/UriBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public void CrossCheck()
{
Uri uri = UriBuilder.Create("some/kind/{of}/uri", UriKind.Relative)
.AddQueryParam("name", "luke")
.AddQueryParam("id", "")
.AddQueryParam("omitnull", (int?)null)
.AddQueryParam("id", (int?)null)
.AddQueryParam("omitdefaultnullint", (int?)null, null)
.AddQueryParam("omitdefaultnullstring", (string?)null, null)
.AddQueryParam("omitdefaultprimitive", 3, 3)
Expand Down

0 comments on commit 2199c99

Please sign in to comment.