Skip to content

Commit

Permalink
Fix bug #100
Browse files Browse the repository at this point in the history
  • Loading branch information
justinyoo committed Aug 3, 2020
1 parent 9b260e2 commit 1970691
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ 'windows-latest' ]
dotnet: [ '3.1.301' ]
dotnet: [ '3.1.302' ]

runs-on: ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ 'windows-latest' ]
dotnet: [ '3.1.301' ]
dotnet: [ '3.1.302' ]

runs-on: ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ 'windows-latest' ]
dotnet: [ '3.1.301' ]
dotnet: [ '3.1.302' ]

runs-on: ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
os: [ 'windows-latest' ]
node: [ 10 ]
dotnet: [ '3.1.301' ]
dotnet: [ '3.1.302' ]
targetFramework: [ 'net461', 'netcoreapp3.1' ]
runtime: [ 'win-x64', 'linux-x64', 'osx-x64' ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,26 @@ private static bool IsArrayType(this Type type)
return true;
}

if (type.IsGenericTypeOf(typeof(ICollection<>)))
{
return true;
}

if (type.IsGenericTypeOf(typeof(IEnumerable<>)))
{
return true;
}

if (type.IsGenericTypeOf(typeof(IReadOnlyList<>)))
{
return true;
}

if (type.IsGenericTypeOf(typeof(IReadOnlyCollection<>)))
{
return true;
}

return false;
}

Expand All @@ -561,6 +576,16 @@ private static bool IsDictionaryType(this Type type)
return true;
}

if (type.Name.Equals("IReadOnlyDictionary`2", StringComparison.CurrentCultureIgnoreCase))
{
return true;
}

if (type.Name.Equals("KeyValuePair`2", StringComparison.CurrentCultureIgnoreCase))
{
return true;
}

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public void Given_Type_When_IsNavigatable_Invoked_Then_It_Should_Return_Result(T

[DataTestMethod]
[DataRow(typeof(Dictionary<string, string>), true)]
[DataRow(typeof(IDictionary<string, string>), true)]
[DataRow(typeof(IReadOnlyDictionary<string, string>), true)]
[DataRow(typeof(KeyValuePair<string, string>), true)]
[DataRow(typeof(int), false)]
public void Given_Type_When_IsVisitable_Invoked_Then_It_Should_Return_Result(Type type, bool expected)
{
Expand All @@ -53,6 +56,9 @@ public void Given_Type_When_IsVisitable_Invoked_Then_It_Should_Return_Result(Typ

[DataTestMethod]
[DataRow(typeof(Dictionary<string, string>), false)]
[DataRow(typeof(IDictionary<string, string>), false)]
[DataRow(typeof(IReadOnlyDictionary<string, string>), false)]
[DataRow(typeof(KeyValuePair<string, string>), false)]
[DataRow(typeof(int), false)]
public void Given_Type_When_IsParameterVisitable_Invoked_Then_It_Should_Return_Result(Type type, bool expected)
{
Expand All @@ -63,6 +69,9 @@ public void Given_Type_When_IsParameterVisitable_Invoked_Then_It_Should_Return_R

[DataTestMethod]
[DataRow(typeof(Dictionary<string, string>), true)]
[DataRow(typeof(IDictionary<string, string>), true)]
[DataRow(typeof(IReadOnlyDictionary<string, string>), true)]
[DataRow(typeof(KeyValuePair<string, string>), true)]
[DataRow(typeof(int), false)]
public void Given_Type_When_IsPayloadVisitable_Invoked_Then_It_Should_Return_Result(Type type, bool expected)
{
Expand All @@ -73,7 +82,13 @@ public void Given_Type_When_IsPayloadVisitable_Invoked_Then_It_Should_Return_Res

[DataTestMethod]
[DataRow(typeof(Dictionary<string, string>), "object", null, "string", false, "string", 0)]
[DataRow(typeof(IDictionary<string, string>), "object", null, "string", false, "string", 0)]
[DataRow(typeof(IReadOnlyDictionary<string, string>), "object", null, "string", false, "string", 0)]
[DataRow(typeof(KeyValuePair<string, string>), "object", null, "string", false, "string", 0)]
[DataRow(typeof(Dictionary<string, FakeModel>), "object", null, "object", true, "fakeModel", 1)]
[DataRow(typeof(IDictionary<string, FakeModel>), "object", null, "object", true, "fakeModel", 1)]
[DataRow(typeof(IReadOnlyDictionary<string, FakeModel>), "object", null, "object", true, "fakeModel", 1)]
[DataRow(typeof(KeyValuePair<string, FakeModel>), "object", null, "object", true, "fakeModel", 1)]
public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(Type dictionaryType, string dataType, string dataFormat, string additionalPropertyType, bool isReferential, string referenceId, int expected)
{
var name = "hello";
Expand Down Expand Up @@ -118,6 +133,9 @@ public void Given_Attribute_When_Visit_Invoked_Then_It_Should_Return_Result(Open

[DataTestMethod]
[DataRow(typeof(Dictionary<string, string>), "object", null, null)]
[DataRow(typeof(IDictionary<string, string>), "object", null, null)]
[DataRow(typeof(IReadOnlyDictionary<string, string>), "object", null, null)]
[DataRow(typeof(KeyValuePair<string, string>), "object", null, null)]
public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result(Type dictionaryType, string dataType, string dataFormat, OpenApiSchema expected)
{
var result = this._visitor.ParameterVisit(dictionaryType, this._strategy);
Expand All @@ -127,7 +145,13 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result(

[DataTestMethod]
[DataRow(typeof(Dictionary<string, string>), "object", null, "string", "string")]
[DataRow(typeof(IDictionary<string, string>), "object", null, "string", "string")]
[DataRow(typeof(IReadOnlyDictionary<string, string>), "object", null, "string", "string")]
[DataRow(typeof(KeyValuePair<string, string>), "object", null, "string", "string")]
[DataRow(typeof(Dictionary<string, FakeModel>), "object", null, "object", "fakeModel")]
[DataRow(typeof(IDictionary<string, FakeModel>), "object", null, "object", "fakeModel")]
[DataRow(typeof(IReadOnlyDictionary<string, FakeModel>), "object", null, "object", "fakeModel")]
[DataRow(typeof(KeyValuePair<string, FakeModel>), "object", null, "object", "fakeModel")]
public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(Type dictionaryType, string dataType, string dataFormat, string additionalPropertyType, string referenceId)
{
var result = this._visitor.PayloadVisit(dictionaryType, this._strategy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public void Given_Type_When_IsNavigatable_Invoked_Then_It_Should_Return_Result(T

[DataTestMethod]
[DataRow(typeof(List<string>), true)]
[DataRow(typeof(IList<string>), true)]
[DataRow(typeof(ICollection<string>), true)]
[DataRow(typeof(IEnumerable<string>), true)]
[DataRow(typeof(IReadOnlyList<string>), true)]
[DataRow(typeof(IReadOnlyCollection<string>), true)]
[DataRow(typeof(int), false)]
public void Given_Type_When_IsVisitable_Invoked_Then_It_Should_Return_Result(Type type, bool expected)
{
Expand All @@ -53,6 +58,11 @@ public void Given_Type_When_IsVisitable_Invoked_Then_It_Should_Return_Result(Typ

[DataTestMethod]
[DataRow(typeof(List<string>), true)]
[DataRow(typeof(IList<string>), true)]
[DataRow(typeof(ICollection<string>), true)]
[DataRow(typeof(IEnumerable<string>), true)]
[DataRow(typeof(IReadOnlyList<string>), true)]
[DataRow(typeof(IReadOnlyCollection<string>), true)]
[DataRow(typeof(int), false)]
public void Given_Type_When_IsParameterVisitable_Invoked_Then_It_Should_Return_Result(Type type, bool expected)
{
Expand All @@ -63,6 +73,11 @@ public void Given_Type_When_IsParameterVisitable_Invoked_Then_It_Should_Return_R

[DataTestMethod]
[DataRow(typeof(List<string>), true)]
[DataRow(typeof(IList<string>), true)]
[DataRow(typeof(ICollection<string>), true)]
[DataRow(typeof(IEnumerable<string>), true)]
[DataRow(typeof(IReadOnlyList<string>), true)]
[DataRow(typeof(IReadOnlyCollection<string>), true)]
[DataRow(typeof(int), false)]
public void Given_Type_When_IsPayloadVisitable_Invoked_Then_It_Should_Return_Result(Type type, bool expected)
{
Expand All @@ -73,7 +88,17 @@ public void Given_Type_When_IsPayloadVisitable_Invoked_Then_It_Should_Return_Res

[DataTestMethod]
[DataRow(typeof(List<string>), "array", null, "string", false, "string", 0)]
[DataRow(typeof(IList<string>), "array", null, "string", false, "string", 0)]
[DataRow(typeof(ICollection<string>), "array", null, "string", false, "string", 0)]
[DataRow(typeof(IEnumerable<string>), "array", null, "string", false, "string", 0)]
[DataRow(typeof(IReadOnlyList<string>), "array", null, "string", false, "string", 0)]
[DataRow(typeof(IReadOnlyCollection<string>), "array", null, "string", false, "string", 0)]
[DataRow(typeof(List<FakeModel>), "array", null, "object", true, "fakeModel", 1)]
[DataRow(typeof(IList<FakeModel>), "array", null, "object", true, "fakeModel", 1)]
[DataRow(typeof(ICollection<FakeModel>), "array", null, "object", true, "fakeModel", 1)]
[DataRow(typeof(IEnumerable<FakeModel>), "array", null, "object", true, "fakeModel", 1)]
[DataRow(typeof(IReadOnlyList<FakeModel>), "array", null, "object", true, "fakeModel", 1)]
[DataRow(typeof(IReadOnlyCollection<FakeModel>), "array", null, "object", true, "fakeModel", 1)]
public void Given_Type_When_Visit_Invoked_Then_It_Should_Return_Result(Type listType, string dataType, string dataFormat, string itemType, bool isReferential, string referenceId, int expected)
{
var name = "hello";
Expand Down Expand Up @@ -118,7 +143,17 @@ public void Given_Attribute_When_Visit_Invoked_Then_It_Should_Return_Result(Open

[DataTestMethod]
[DataRow(typeof(List<string>), "array", null, "string", false)]
[DataRow(typeof(IList<string>), "array", null, "string", false)]
[DataRow(typeof(ICollection<string>), "array", null, "string", false)]
[DataRow(typeof(IEnumerable<string>), "array", null, "string", false)]
[DataRow(typeof(IReadOnlyList<string>), "array", null, "string", false)]
[DataRow(typeof(IReadOnlyCollection<string>), "array", null, "string", false)]
[DataRow(typeof(List<FakeModel>), "array", null, "object", true)]
[DataRow(typeof(IList<FakeModel>), "array", null, "object", true)]
[DataRow(typeof(ICollection<FakeModel>), "array", null, "object", true)]
[DataRow(typeof(IEnumerable<FakeModel>), "array", null, "object", true)]
[DataRow(typeof(IReadOnlyList<FakeModel>), "array", null, "object", true)]
[DataRow(typeof(IReadOnlyCollection<FakeModel>), "array", null, "object", true)]
public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result(Type listType, string dataType, string dataFormat, string itemType, bool isItemToBeNull)
{
var result = this._visitor.ParameterVisit(listType, this._strategy);
Expand All @@ -135,7 +170,17 @@ public void Given_Type_When_ParameterVisit_Invoked_Then_It_Should_Return_Result(

[DataTestMethod]
[DataRow(typeof(List<string>), "array", null, "string", "string")]
[DataRow(typeof(IList<string>), "array", null, "string", "string")]
[DataRow(typeof(ICollection<string>), "array", null, "string", "string")]
[DataRow(typeof(IEnumerable<string>), "array", null, "string", "string")]
[DataRow(typeof(IReadOnlyList<string>), "array", null, "string", "string")]
[DataRow(typeof(IReadOnlyCollection<string>), "array", null, "string", "string")]
[DataRow(typeof(List<FakeModel>), "array", null, "object", "fakeModel")]
[DataRow(typeof(IList<FakeModel>), "array", null, "object", "fakeModel")]
[DataRow(typeof(ICollection<FakeModel>), "array", null, "object", "fakeModel")]
[DataRow(typeof(IEnumerable<FakeModel>), "array", null, "object", "fakeModel")]
[DataRow(typeof(IReadOnlyList<FakeModel>), "array", null, "object", "fakeModel")]
[DataRow(typeof(IReadOnlyCollection<FakeModel>), "array", null, "object", "fakeModel")]
public void Given_Type_When_PayloadVisit_Invoked_Then_It_Should_Return_Result(Type listType, string dataType, string dataFormat, string itemType, string referenceId)
{
var result = this._visitor.PayloadVisit(listType, this._strategy);
Expand Down

0 comments on commit 1970691

Please sign in to comment.