Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Map top level meta data from ITopLevelDocument rather than IObjectMetaData #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/NJsonApiCore/Serialization/JsonApiTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public CompoundDocument Transform(object objectGraph, Context context)

var result = new CompoundDocument
{
Meta = transformationHelper.GetMetadata(objectGraph)
Meta = transformationHelper.GetTopLevelMetadata(objectGraph)
};

var resource = transformationHelper.UnwrapResourceObject(objectGraph);
Expand Down
6 changes: 3 additions & 3 deletions src/NJsonApiCore/Serialization/TransformationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ public object UnwrapResourceObject(object objectGraph)
return objectGraph;
}

public IMetaData GetMetadata(object objectGraph)
public IMetaData GetTopLevelMetadata(object objectGraph)
{
if (objectGraph is IObjectMetaDataContainer)
if (objectGraph is ITopLevelDocument)
{
var metaDataContainer = objectGraph as IObjectMetaDataContainer;
var metaDataContainer = objectGraph as ITopLevelDocument;
return metaDataContainer.GetMetaData();
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void Creates_CompoundDocument_for_single_class_with_metadata_and_properly
var transformedObject = result.Data as SingleResource;
Assert.Equal("value1", transformedObject.MetaData["meta1"]);
Assert.Equal("value2", transformedObject.MetaData["meta2"]);
Assert.Null(result.Meta);
}

[Fact]
Expand Down