There are also example apps which use the contracts (see the site)
c
Codecraig
12/12/2018, 1:06 PM
So, if I understand correctly, the contract allows http4k to validate a request against the "OpenApi" contract, which takes that work away from the developer, right?
How does JSON Schema fit in? My experience with JSON Schema, outside of http4k, has been 1) define a schema, 2) validate JSON against it (such as the body of an HTTP request)
d
dave
12/12/2018, 1:10 PM
http4k will only validate the contents of the path (so it can match the handler) before dispatching the request to the handler. the rest of the parameters are checked only when they are accessed by your code, and the CatchLensFailure filter will convert errors to a 400. so you will have to write zero validation code for any defined "primitives" (including datetimes and anything else the lens API supports).
Json schema is really there only for the Swagger interface (it is generated on demand from examples defined in the code). We generally use the Jackson auto marshalling to provide automatic validation of the body schema by defining data classes in the shape that we require (it will blow up in the lens when the body is unmarshalled and cause a 400)