3.1.20191113192440

Version: 3.1.20191113192440

Documentation (pdf)

This release provides many incremental improvements to 3.0 while introducing three major new features.

OpenAPI Support (experimental)

Experimental support for OpenAPI is now available as extension to the Crnk generator. It will generate an OpenAPI schema out of any Crnk endpoint by inspecting the implementation and derive a schema. An example setup looks like:
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.

Bulk Repositories (experimental)

There is a new experimental BulkResourceRepository that closely resembles ResourceRepository but takes multiple resources as arguments. This give the repository the possibility to optimize bulk mutations of multiple resources, like sharing a database transaction. Currently only POST is implemented, not PATCH and DELETE yet! More information can be found here. In future releases this will be aligned with support for the upcoming JSON:API 1.1 specification.
public class BulkInMemoryRepository implements BulkResourceRepository<Task, Long> {

    @Override
    public <S extends T> List<S> create(List<S> resources) {
       ...
    }

    ...
}

TestKit

There is a new project io.crnk:crnk-testkit to facilitate testing of JSON:API based endpoints. As first contribution there is a 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.

Minor Improvements