Created
October 22, 2012 15:13
-
-
Save deathbob/3931960 to your computer and use it in GitHub Desktop.
json schema for hal vs. users.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ruby schema.rb | |
/Users/lovebob/.rvm/gems/ruby-1.9.3-p194@halidator/gems/jsonschema-2.0.2/lib/jsonschema.rb:255:in `check_type': _links > ht:user > ht:user > ht:user: Array value found, but a [{"id"=>"link", "type"=>"object", "properties"=>{"href"=>{"type"=>"string", "title"=>"URI of the target resource", "description"=>"Either a URI [RFC3986] or URI Template [RFC6570] of the target resource."}, "templated"=>{"type"=>"boolean", "optional"=>true, "default"=>false, "title"=>"URI Template", "description"=>"Is true when the link object's href property is a URI Template. Defaults to false."}, "type"=>{"type"=>"string", "pattern"=>"^(application|audio|example|image|message|model|multipart|text|video)\\/[a-zA-Z0-9!#\\$&\\.\\+-\\^_]{1,127}$", "optional"=>true, "title"=>"Media type indication of the target resource", "description"=>"When present, used as a hint to indicate the media type expected when dereferencing the target resource."}, "name"=>{"type"=>"string", "optional"=>true, "title"=>"Secondary key", "description"=>"When present, may be used as a secondary key for selecting link objects that contain the same relation type."}, "profile"=>{"type"=>"string", "format"=>"uri", "optional"=>true, "title"=>"Additional semantics of the target resource", "description"=>"A URI that, when dereferenced, results in a profile to allow clients to learn about additional semantics (constraints, conventions, extensions) that are associated with the target resource representation, in addition to those defined by the HAL media type and relations."}, "title"=>{"type"=>"string", "optional"=>true, "title"=>"Human-readable identifier", "description"=>"When present, is used to label the destination of a link such that it can be used as a human-readable identifier (e.g. a menu entry) in the language indicated by the Content-Language header (if present)."}, "hreflang"=>{"type"=>"string", "pattern"=>"^([a-zA-Z]{2,3}(-[a-zA-Z]{3}(-[a-zA-Z]{3}){0,2})?(-[a-zA-Z]{4})?(-([a-zA-Z]{2}|[0-9]{3}))?(-([a-zA-Z0-9]{5,8}|[0-9][a-zA-Z0-9]{3}))*([0-9A-WY-Za-wy-z](-[a-zA-Z0-9]{2,8}){1,})*(x-[a-zA-Z0-9]{2,8})?)|(x-[a-zA-Z0-9]{2,8})|(en-GB-oed)|(i-ami)|(i-bnn)|(i-default)|(i-enochian)|(i-hak)|(i-klingon)|(i-lux)|(i-mingo)|(i-navajo)|(i-pwn)|(i-tao)|(i-tay)|(i-tsu)|(sgn-BE-FR)|(sgn-BE-NL)|(sgn-CH-DE)|(art-lojban)|(cel-gaulish)|(no-bok)|(no-nyn)|(zh-guoyu)|(zh-hakka)|(zh-min)|(zh-min-nan)|(zh-xiang)$", "optional"=>true, "title"=>"Language indication of the target resource [RFC5988]", "description"=>"When present, is a hint in RFC5646 format indicating what the language of the result of dereferencing the link should be. Note that this is only a hint; for example, it does not override the Content-Language header of a HTTP response obtained by actually following the link."}}, "additionalProperties"=>false}, {"type"=>"array", "items"=>[{"$ref"=>"link"}], "uniqueItems"=>true, "additionalProperties"=>false}] is required (JSON::Schema::ValueError) | |
from /Users/lovebob/.rvm/gems/ruby-1.9.3-p194@halidator/gems/jsonschema-2.0.2/lib/jsonschema.rb:62:in `check_property' | |
from /Users/lovebob/.rvm/gems/ruby-1.9.3-p194@halidator/gems/jsonschema-2.0.2/lib/jsonschema.rb:118:in `block in check_property' | |
from /Users/lovebob/.rvm/gems/ruby-1.9.3-p194@halidator/gems/jsonschema-2.0.2/lib/jsonschema.rb:114:in `each' | |
from /Users/lovebob/.rvm/gems/ruby-1.9.3-p194@halidator/gems/jsonschema-2.0.2/lib/jsonschema.rb:114:in `check_property' | |
from /Users/lovebob/.rvm/gems/ruby-1.9.3-p194@halidator/gems/jsonschema-2.0.2/lib/jsonschema.rb:219:in `block in check_object' | |
from /Users/lovebob/.rvm/gems/ruby-1.9.3-p194@halidator/gems/jsonschema-2.0.2/lib/jsonschema.rb:217:in `each' | |
from /Users/lovebob/.rvm/gems/ruby-1.9.3-p194@halidator/gems/jsonschema-2.0.2/lib/jsonschema.rb:217:in `check_object' | |
from /Users/lovebob/.rvm/gems/ruby-1.9.3-p194@halidator/gems/jsonschema-2.0.2/lib/jsonschema.rb:108:in `check_property' | |
from /Users/lovebob/.rvm/gems/ruby-1.9.3-p194@halidator/gems/jsonschema-2.0.2/lib/jsonschema.rb:297:in `validate' | |
from /Users/lovebob/.rvm/gems/ruby-1.9.3-p194@halidator/gems/jsonschema-2.0.2/lib/jsonschema.rb:308:in `validate' | |
from schema.rb:8:in `<main>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'json' | |
require 'jsonschema' | |
schema = File.open("./hal.json", "rb"){|f| JSON.parse(f.read)} | |
data = open('http://haltalk.herokuapp.com/users.json'){|f| JSON.parse(f.read)} | |
puts JSON::Schema.validate(data, schema) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment