Support for inheritance with a single repository per type hierarchy
A new attribute subTypes was introduced to @JsonApiResource to specify an inheritance relationship. For example:
@JsonApiResource(type = "task", subTypes = SpecialTask.class)
public class Task {
// fields, getters and setters
}
@JsonApiResource(type = "specialTask", resourcePath = "task")
public class SpecialTask extends Task{
// fields, getters and setters
}
SpecialTask extends Task but is configured to use the same resourcePath, meaning SpecialTask does not have to bring
along its own repository implementation, but is served by the task repository.
For more information have a look at the documentation.
Microservice example
There is a new spring-boot-microservice-example application. It showcases how to establish relationships between resources of two separate microservices.
The relationship supports the full JSON API feature, most notable the use of inclusions. Behind the scenes crnk-client is used to let one Crnk instance
access another Crnk instance.
@JsonApiExpose annotation
@JsonApiExpose can be used to hide a resource repository from the JSON API endpoint. It is used by the preceding microservice example to hide the
remote repositories on the local endpoint while making them available internally to perform relationship inclusions.
InMemoryResourceRepository default implementation
There is a default implementation for a in-memory resource repository that is backed by a ConcurrentHashMap. It can be useful to get started quickly,
use for mocking and work with small data sets.
Spring Boot Auto Configuration for Tomcat 8.5+
There is a bit of a controversy about which characters to encode or not encode in URLs based on
RFC 7230 and RFC 3986. JSON API is affected in that regard due to the use of [ and ].
Browser vendors have yet to endorse those RFCs. But unfortunately, Tomcat already started
to enforce the RFCs from their side. As such it is useful to
relax the [ and ] characters to simplify development with JSON API, like entering
URLs manually in the browser. For this purpose `relaxedPathChars` can be set to `[]`, for more information
see
https://stackoverflow.com/questions/41053653/tomcat-8-is-not-able-to-handle-get-request-with-in-query-parameters
The Spring Boot auto configuration already does this out-of-the-box with this release.
Comma-separated filter parameters
Multiple filter values can now be separated by comma:
http://127.0.0.1:8080/api/tasks?filter[name][EQ]=SomeTask,OtherTask
Repositories then will typically use an OR to return resources matching any of one the filter values.
The behavior can be disabled in DefaultQuerySpecUrlMapper.setAllowCommaSeparatedValue(...) if desired.
More flexible typing for FilterOperator
By default Crnk uses a simplistic model for filtering where the type of a filter value matches the type of the attribute to be filtered. This works
well in many occasions, but there are also some exceptions. For example, the LIKE operator is always of type String to support wildcards, whereas
the attribute it self may not. One such example is the LIKE-filtering of Enums. For this reason a FilterOperator.getFilterType() was introduced
to allow the FilterOperator influence the typing of filter values.
Nested Resources
Work started to bring support for nested resource having url patterns like http://example.com/posts/1/comments/2. For more information
you can check out the nested resource section in the documentation. However, this feature is still considered (very) experimental
and will be refined and more thoroughly tested in subsequent releases. Help to finish it is welcomed.