Skip to content

Commit bacdc8c

Browse files
Deduplicate included resources in JSON:API response
1 parent fda4a4a commit bacdc8c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

JsonApiToolkit/Mapping/JsonApiMapper.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ public static JsonApiDocument<ResourceObject> ToDocument<T>(
230230
InclusionMapper.AddIncludedResources(entity, includedRelationships, included);
231231
if (included.Count > 0)
232232
{
233-
document.Included = included;
233+
document.Included = included
234+
.GroupBy(r => new { r.Type, r.Id })
235+
.Select(g => g.First())
236+
.ToList();
234237
}
235238
}
236239

0 commit comments

Comments
 (0)