-
Notifications
You must be signed in to change notification settings - Fork 156
Description
Issue
Given a resource named main having one related resource named related of type a, and a have a sub-type b, and using @JsonApiRelation(lookup=AUTOMATICALLY_WHEN_NULL) and @JsonApiRelationId
When requesting main using include=related and repository implementation of main fills the id of related, but this id matches an instance of b (which extends a).
Result the type of related in relationships section is a, the type of related in included section is b
Expected Same type, ideally b into the 2 sections.
Example :
Resources
@JsonApiResource(type = "main")
public class MainResource {
@JsonApiId
private String id;
@JsonApiRelationId
private String relatedId
@JsonApiRelation(lookUp = LookupIncludeBehavior.AUTOMATICALLY_WHEN_NULL)
private A related;
}
@JsonApiResource(type = "a", subTypes = RelatedResourceB.class)
public class RelatedResourceA {
@JsonApiId
private String id;
private String data;
}
@JsonApiResource(type = "b", resourcePath="a")
public class RelatedResourceB extends RelatedResourceA {
private String otherData;
}NB: Getters and setters are omitted for brevity.
Requests
NB: requests are written with httpie, for these examples, you just have to know that 'x==y' means add a request parameter x with value y.
http :8080/main/mainId include==related
{
"data": {
"id": "mainId",
"links": " [...] "
"relationships": {
"related": {
"data": {
"id": "mainId.B",
"type": "a"
},
"links": " [...] "
}
},
"type": "main"
},
"included": [
{
"attributes": {
"data": "Label from resource B",
"otherData": "Other"
},
"id": "mainId.B",
"links": " [...] ",
"type": "b"
}
],
"links": " [...] "
}data.relationships.related.data.type should match included[0].type
Remark
I know that having Crnk returning type b if included=related is not specified is not possible. But when included is present, types should match.