diff --git a/Octokit.Tests/Models/RepositoryRequestTests.cs b/Octokit.Tests/Models/RepositoryRequestTests.cs
new file mode 100644
index 0000000000..e5d89562fc
--- /dev/null
+++ b/Octokit.Tests/Models/RepositoryRequestTests.cs
@@ -0,0 +1,50 @@
+using Xunit;
+
+namespace Octokit.Tests.Models
+{
+ public class RepositoryRequestTests
+ {
+ public class TheToParametersDictionaryMethod
+ {
+ [Fact]
+ public void ContainsSetValues()
+ {
+ var request = new RepositoryRequest
+ {
+ Type = RepositoryType.All,
+ Sort = RepositorySort.FullName,
+ Direction = SortDirection.Ascending
+ };
+
+ var parameters = request.ToParametersDictionary();
+
+ Assert.Equal(3, parameters.Count);
+ Assert.Equal("all", parameters["type"]);
+ Assert.Equal("full_name", parameters["sort"]);
+ Assert.Equal("asc", parameters["direction"]);
+
+ request = new RepositoryRequest
+ {
+ Affiliation = RepositoryAffiliation.All,
+ Visibility = RepositoryVisibility.Public
+ };
+
+ parameters = request.ToParametersDictionary();
+
+ Assert.Equal(2, parameters.Count);
+ Assert.Equal("owner, collaborator, organization_member", parameters["affiliation"]);
+ Assert.Equal("public", parameters["visibility"]);
+ }
+
+ [Fact]
+ public void DoesNotReturnValuesForDefaultRequest()
+ {
+ var request = new RepositoryRequest();
+
+ var parameters = request.ToParametersDictionary();
+
+ Assert.Empty(parameters);
+ }
+ }
+ }
+}
diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj
index 99537721eb..5c6484c309 100644
--- a/Octokit.Tests/Octokit.Tests.csproj
+++ b/Octokit.Tests/Octokit.Tests.csproj
@@ -182,6 +182,7 @@
+
diff --git a/Octokit/Models/Request/RepositoryRequest.cs b/Octokit/Models/Request/RepositoryRequest.cs
index 1f5d2e8907..03753b432e 100644
--- a/Octokit/Models/Request/RepositoryRequest.cs
+++ b/Octokit/Models/Request/RepositoryRequest.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
@@ -19,7 +20,7 @@ public class RepositoryRequest : RequestParameters
/// The type.
///
[SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
- public RepositoryType Type { get; set; }
+ public RepositoryType? Type { get; set; }
///
/// Gets or sets the sort property.
@@ -27,7 +28,7 @@ public class RepositoryRequest : RequestParameters
///
/// The sort.
///
- public RepositorySort Sort { get; set; }
+ public RepositorySort? Sort { get; set; }
///
/// Gets or sets the sort direction.
@@ -35,7 +36,7 @@ public class RepositoryRequest : RequestParameters
///
/// The direction.
///
- public SortDirection Direction { get; set; }
+ public SortDirection? Direction { get; set; }
///
/// Gets or sets the visibility property.
@@ -43,7 +44,7 @@ public class RepositoryRequest : RequestParameters
///
/// The visibility.
///
- public RepositoryVisibility Visibility { get; set; }
+ public RepositoryVisibility? Visibility { get; set; }
///
/// Gets or sets the affiliation property.
@@ -51,13 +52,25 @@ public class RepositoryRequest : RequestParameters
///
/// The affiliation.
///
- public RepositoryAffiliation Affiliation { get; set; }
+ public RepositoryAffiliation? Affiliation { get; set; }
internal string DebuggerDisplay
{
get
{
- return string.Format(CultureInfo.InvariantCulture, "Type: {0}, Sort: {1}, Direction: {2}", Type, Sort, Direction);
+ var propValues = new List();
+ if (Type.HasValue)
+ propValues.Add(string.Format(CultureInfo.InvariantCulture, "Type: {0}", Type));
+ if (Sort.HasValue)
+ propValues.Add(string.Format(CultureInfo.InvariantCulture, "Sort: {0}", Sort));
+ if (Direction.HasValue)
+ propValues.Add(string.Format(CultureInfo.InvariantCulture, "Direction: {0}", Direction));
+ if (Visibility.HasValue)
+ propValues.Add(string.Format(CultureInfo.InvariantCulture, "Visibility: {0}", Visibility));
+ if (Affiliation.HasValue)
+ propValues.Add(string.Format(CultureInfo.InvariantCulture, "Affiliation: {0}", Affiliation));
+
+ return string.Join(", ", propValues);
}
}
}
diff --git a/Octokit/Models/Request/RequestParameters.cs b/Octokit/Models/Request/RequestParameters.cs
index fa689f8c76..ccd7121ca9 100644
--- a/Octokit/Models/Request/RequestParameters.cs
+++ b/Octokit/Models/Request/RequestParameters.cs
@@ -49,6 +49,9 @@ static List GetPropertyParametersForType(Type type)
Justification = "GitHub API depends on lower case strings")]
static Func GetValueFunc(Type propertyType)
{
+ // get underlying type if nullable
+ propertyType = Nullable.GetUnderlyingType(propertyType) ?? propertyType;
+
if (typeof(IEnumerable).IsAssignableFrom(propertyType))
{
return (prop, value) =>