`
@JsonApiResource(type = "superTasks", subTypes = SpecialTask.class)
public abstract class SuperTask {
@JsonApiId
private Long id;
private String name;
private String category;
}
@JsonApiResource(type = "specialTask", resourcePath = "superTasks")
public class SpecialTask extends SuperTask {
private boolean recurring;
private String end;
}
`
Getters and setters have been omitted for brevity.
Requesting path superTasks with request parameter, we get :
:heavy_check_mark: fields[specialTask]=name returns json including only attribute name.
:heavy_check_mark: fields[specialTask]=end returns json including only attribute end.
:heavy_check_mark: fields[specialTask]=name,end returns json including only attributes name and end.
:negative_squared_cross_mark: fields[superTasks]=namereturns json including all attributes (from SpecialTask and SuperTask).
:negative_squared_cross_mark: fields[superTasks]=name and fields[specialTask]=end returns json including only attribute end.
Expected responses :
:heavy_check_mark: fields[specialTask]=name returns json including only attribute name.
:heavy_check_mark: fields[specialTask]=end returns json including only attribute end.
:heavy_check_mark: fields[specialTask]=name,end returns json including only attributes name and end.
:heavy_check_mark: fields[superTasks]=name returns json including only attribute name.
:heavy_check_mark: fields[superTasks]=name and fields[specialTask]=end returns json including only attributes name and end.
At the moment, introducing a new type in the hierarchy (a sibling for SpecialTask) creates a breaking change for our customers, because we need them to specifiy fields for all sub-types.
When using request parameter field, if specifying a super type of the resource requested, the parameter is not taken into account.
Let's define two resources, SuperTask and SpecialTask, the latter inheriting the former, using a single repository per type hierarchy (as stated here : https://www.crnk.io/releases/stable/documentation/#_inheritance) :
` @JsonApiResource(type = "superTasks", subTypes = SpecialTask.class) public abstract class SuperTask {
}
@JsonApiResource(type = "specialTask", resourcePath = "superTasks") public class SpecialTask extends SuperTask {
} ` Getters and setters have been omitted for brevity.
Requesting path superTasks with request parameter, we get :
fields[specialTask]=name
returns json including only attributename
.fields[specialTask]=end
returns json including only attributeend
.fields[specialTask]=name,end
returns json including only attributesname
andend
.fields[superTasks]=name
returns json including all attributes (from SpecialTask and SuperTask).fields[superTasks]=name
andfields[specialTask]=end
returns json including only attributeend
.Expected responses :
fields[specialTask]=name
returns json including only attributename
.fields[specialTask]=end
returns json including only attributeend
.fields[specialTask]=name,end
returns json including only attributesname
andend
.fields[superTasks]=name
returns json including only attributename
.fields[superTasks]=name
andfields[specialTask]=end
returns json including only attributesname
andend
.At the moment, introducing a new type in the hierarchy (a sibling for SpecialTask) creates a breaking change for our customers, because we need them to specifiy fields for all sub-types.