To interactively execute any of the tutorial examples below, I recommend using this validator, which implements the fge/json-schema-validator code from Git Hub.
Similar to the previous tutorial, our model will eventually look like this: package be.g00glen00b.controller; import *; import org.springframework.beans.factory.annotation. Idea Repository; @Rest Controller @Request Mapping("/api/ideas") public class Idea Controller This example looks fine except that there’s one problem… You can easily add ideas that have no title (which should be required) or you can enter a title/description that has any length, eventually surpassing the database limits resulting in unexpected exceptions/behavior.
Autowired; import org.springframework.validation.annotation. Validated; import org.bind.annotation.*; import be.g00glen00b.model. Since we added HSQLDB to our dependencies, Spring Boot will automatically set up the entity manager to use an in memory HSQLDB.
It eliminates the need to write application code that loads the validator and then executes the schema against the input.
This really simplifies the entire process of trying out a schema.
In fact, if you have ever written an XML schema, then JSON schema should be quite familiar to you. At Constant Contact we are mostly a Java shop, and the validator from Francis Galliegue (aka fge) works quite well for us.