Skip to content

HasValue1 returns false for ItemList of ListItems #419

Open
@dermotblairca

Description

@dermotblairca

Describe the bug

I'm not 100% sure if this is a bug or not but I have json which contains an ItemList of ListItems and HasValue1 returns false on the ItemListElement and HasValue3 returns true.
HasValue1 = Gets a value indicating whether the value of type IListItem has a value.
HasValue3 = Gets a value indicating whether the value of type IThing has a value.
Even though ListItem inherits from Thing, should HasValue1 not return true here since it the type of the objects is ListItem?

{
	"@context": "https://schema.org",
	"@type": "ItemList",
	"itemListElement": [
		{
			"@type": "ListItem",
			"description": "test1",
			"url": "http://test1.com",
			"position": 0
		},
		{
			"@type": "ListItem",
			"description": "test2",
			"url": "http://test2.com",
			"position": 1
		}
	]
}

Steps to reproduce

Run the following unit test:

[Fact]
    public void Deserializing_ItemListJsonLd_HasItemListReturnsTrue()
    {
        var json = "{\"@context\":\"https://schema.org\",\"@type\":\"ItemList\",\"itemListElement\":[{\"@type\":\"ListItem\",\"description\":\"test1\",\"url\":\"http://test1.com\",\"position\":0},{\"@type\":\"ListItem\",\"description\":\"test2\",\"url\":\"http://test2.com\",\"position\":1}]}";
        var itemList = SchemaSerializer.DeserializeObject<ItemList>(json);
        Assert.Equal(true, itemList?.ItemListElement.HasValue1);
    }

Expected behaviour

Not 100% sure but I thought HasValue1 would return true here.

Schema objects

https://schema.org/ItemList

Metadata

Metadata

Assignees

Labels

bugIssues describing a bug or pull requests fixing a bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions