Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions APIMatic.Core.Test/Utilities/OneOfContainerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ public void TestNativeType()
});
}

[Test]
public void TestNativeTypeWithNullValue()
{
NativeOneOfContainer container = CoreHelper.JsonDeserialize<NativeOneOfContainer>("null");

Assert.IsNull(container);
}

[Test]
public void TestNativeNullableType()
{
Expand Down
6 changes: 6 additions & 0 deletions APIMatic.Core/Utilities/Converters/UnionTypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ private T DeserializeOneOfAnyOf(JToken token, JsonSerializer serializer, List<Un
return mappedValues[0].value;
}

if (token.Type == JTokenType.Null)
{
// allow null values to pass as the OAF containers are nullable by default
return default;
}

if (_isOneOf)
{
throw new OneOfValidationException(unMappedTypes, token.ToString());
Expand Down