You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a requirement to build a JSON API compliant endpoint which returns an entity without its related data. The user would then request the relationship data separately. For example:
As you can see the data property is an empty array. This is somewhat misleading because there are related items, we have just not included them in this response.
In this section of the JSON:API specification, it shows that it is not required within the relationship section to show the data attribute. It is compliant to only have a links member and no data member.
Is there any way from the controller or via configuration I could omit the array from my response in order to be compliant with the specification and not give the impression the related data is empty?
Environment
JsonApiDotNetCore Version: 3.0.0
The text was updated successfully, but these errors were encountered:
It actually should omit the relationship.data by default unless the navigation property value is being initialized somewhere. This is one reason it can happen.
Description
I have a requirement to build a JSON API compliant endpoint which returns an entity without its related data. The user would then request the relationship data separately. For example:
Entity Request:
v1/myentity/{entity-id}
.Entity Relationship Request:
v1/myentity/{entity-id}/items
.My endpoint currently returns this when an entity request is made:
As you can see the
data
property is an empty array. This is somewhat misleading because there are relateditems
, we have just not included them in this response.In this section of the JSON:API specification, it shows that it is not required within the relationship section to show the data attribute. It is compliant to only have a
links
member and nodata
member.Is there any way from the controller or via configuration I could omit the array from my response in order to be compliant with the specification and not give the impression the related data is empty?
Environment
The text was updated successfully, but these errors were encountered: