Skip to content

Commit 0baf63d

Browse files
author
Bart Koelman
committed
Added explanation on why 'id' is added to the attribute set
1 parent d9d765f commit 0baf63d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/JsonApiDotNetCore/Builders/ResourceGraphBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ protected virtual List<AttrAttribute> GetAttributes(Type entityType)
9292
{
9393
var attribute = (AttrAttribute)property.GetCustomAttribute(typeof(AttrAttribute));
9494

95-
// TODO: investigate why this is added in the exposed attributes list
96-
// because it is not really defined attribute considered from the json:api
97-
// spec point of view.
95+
// Although strictly not correct, 'id' is added to the list of attributes for convenience.
96+
// For example, it enables to filter on id, without the need to special-case existing logic.
97+
// And when using sparse fields, it silently adds 'id' to the set of attributes to retrieve.
9898
if (property.Name == nameof(Identifiable.Id) && attribute == null)
9999
{
100100
var idAttr = new AttrAttribute

0 commit comments

Comments
 (0)