compile group: "org.http4k", name: "http4k-contract", version: "2.21.2"
http4k-contract module adds a much more sophisticated routing mechanism to that available in
http4k-core. It adds the facility
to declare server-side
Routes in a completely typesafe way, leveraging the Lens functionality from the core. These
RouteModules, which have the following features:
- Auto-validating - the
Routecontract is automatically validated on each call for required-fields and type conversions, removing the requirement for any validation code to be written by the API user. Invalid calls result in a
HTTP 400 (BAD_REQUEST)response.
- Self-describing: - a generated endpoint is provided which describes all of the
Routesin that module. Implementations include Swagger/OpenAPI documentation, including generation of [JSON schema] (http://json-schema.org/) models for messages.
- Security: to secure the
Routesagainst unauthorised access. Current implementations include
When launched, Swagger format documentation (including JSON schema models) can be found at the route of the module.
For a more extended example, see the following example apps: