This release provides many incremental improvements to 3.0 while introducing three major new features.
buildscript { dependencies { classpath "io.crnk:crnk-gen-gradle:${version}" } } apply plugin: 'crnk-gen' crnkGen { runtime { configuration = 'openapiGenRuntime' } // fork generation into new process to have clean environment forked = true // specify the package to look for resources resourcePackages = ['io.crnk.test'] openapi { // enable OpenAPI generation within Gradle plugin enabled = true // specify name of openapi template in the build dir to merge onto templateName = "openapi-template.yml" // specify name of API to display in the generated OpenAPI file projectName = "Generated Title" // specify version of the API to display in the generated OpenAPI file projectVersion = "0.1.0" // specify name of openapi template in the build dir to merge onto projectDescription = "A generated description of the API." // specify location of generated sources genDir = file('src/resources') } } } crnkGen.init()Fore more information see here. Have a look at the GitHub tickets for the future roadmap.
public class BulkInMemoryRepository implements BulkResourceRepository<Task, Long> { @Override public <S extends T> List<S> create(List<S> resources) { ... } ... }
RandomWalkLinkChecker
:
CrnkClient client = ... HttpAdapter httpAdapter = client.getHttpAdapter(); RandomWalkLinkChecker linkChecker = new RandomWalkLinkChecker(httpAdapter); linkChecker.setWalkLength(100); linkChecker.addStartUrl(...) linkChecker.performCheck();It performs a random walk on an API endpoint by following the links as specified by JSON:API. It will verify that each links provides a valid 2xx response code. By having a sufficiently long walk, it will ensure that any GET request can be served with high probability. This in turn allows developers to focus on testing business functionality, while lower layer REST details like linking get verified automatically. More information and roadmap are available here.
CrnkClient client = ... ResourceRepository<Task,Long>repository = client.getRepositoryForType(Task.class); repository.findAll(new QuerySpec(Project.class));
meta
and links
to
have a clear distinction to the JSON:API data structures.
@JsonApiResource(type = "project") public class Project { @JsonApiLinksInformation private DefaultSelfLinksInformation links = new DefaultSelfLinksInformation(); ... }
/api/project/{projectId}/tasks/{taskId}
.
/api/tasks
and /api/tasks/history
.
403 FORBIDDEN
.
/api/project/{projectId}/tasks/{taskId}/items/{itemId}
@JsonApiExposed(false)
. It allows there
use on the server-side to consume other services without exposing the repositories again.
When returning resources obtained from such a repository, they will maintain proper linking
to the original service as long a the resources carry a links object implementing
SelfLinksInformation. For an example see
spring-boot-microservice-example
CrnkClient.setObjectMapper(...)
.
ResourceTypeHolder
interfaces allows a resource to hold its resource type. This can proof
useful in more dynamic settings where inheritance is involved and a repository likes to manipulate
the type of its resources without having to work with strongly-typed resource classes. Together
with @JsonAnyGetter and @JsonAnySetter it allows for highly dynamic, non-compile-time repository
implementations similar but simpler than the direct use of the Resource
class.
For information is available in the
documentation.