crnk-project / crnk-framework

JSON API library for Java
Apache License 2.0
287 stars 156 forks source link

Requested fields using super resource type are not taken into account #852

Open lgringo opened 2 years ago

lgringo commented 2 years ago

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 {

@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 :

Expected responses :

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.