I have Book schema, that has a component link to similar books. One of the similar books, has a component link back to original component. In such way I got circular reference.
When publishing this component with DXA 2.0 TBBs expandLinkDepth parameter handles it nicely, and as result I got only couple of levels included in JSON.
However my main issue is on webapp side, it is failing during model mapping.
Book model has next property:
[SemanticProperty("s:similar_books")]
public List<Book> SimilarBooks { get; set; }
Default DataModelBuilder successfully maps couple of levels of Books to my property, however the last level that was restricted by TBB expandLinkDepth is failing with such message:
Unable to map field 'SimilarBooks' to property Book.SimilarBooks of type ...
It fails on this line of BuildEntityModel method of DefaultModelBuilder, because SchemaId is null.
SemanticSchema semanticSchema = SemanticMapping.GetSchema(entityModelData.SchemaId, localization);
Probably we can enhance DXA to avoid exception, however:
How should we handle such circular reference situations in general with DXA Models?
Thanks!
List<Link>
to get the similar books as links to other pages.