Skip to content

Instantly share code, notes, and snippets.

@reitzig
Last active July 3, 2018 17:19
Show Gist options
  • Save reitzig/9fd7c1c2718b46bb43dcd3506ec3437a to your computer and use it in GitHub Desktop.
Save reitzig/9fd7c1c2718b46bb43dcd3506ec3437a to your computer and use it in GitHub Desktop.
{
"b": {
"c": {
"foo": "bar"
}
}
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Schema A",
"type": "object",
"properties": {
"b": {
"$ref": "schemas/more/schemaB.json"
}
}
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Schema B",
"type": "object",
"properties": {
"c": {
"$ref": "schemas/more/schemaC.json"
}
}
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Schema C",
"type": "object",
"properties": {
"foo": {
"type": "string"
}
}
}
#!/usr/bin/env ruby
require 'json-schema'
schemaA = File.read("schemas/stuff/schemaA.json")
example = File.read("example.json")
puts JSON::Validator.validate(schemaA, example) ? 0 : 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment