Hello community, here is the log from the commit of package rubygem-json-schema for openSUSE:Factory checked in at 2017-04-11 09:32:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-json-schema (Old) and /work/SRC/openSUSE:Factory/.rubygem-json-schema.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-json-schema" Tue Apr 11 09:32:03 2017 rev:6 rq:456620 version:2.8.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-json-schema/rubygem-json-schema.changes 2016-10-10 16:22:56.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-json-schema.new/rubygem-json-schema.changes 2017-04-11 09:32:04.775974231 +0200 @@ -1,0 +2,6 @@ +Wed Feb 8 05:44:58 UTC 2017 - coolo@suse.com + +- updated to version 2.8.0 + no changelog found + +------------------------------------------------------------------- Old: ---- json-schema-2.7.0.gem New: ---- json-schema-2.8.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-json-schema.spec ++++++ --- /var/tmp/diff_new_pack.5fOz2d/_old 2017-04-11 09:32:05.535866910 +0200 +++ /var/tmp/diff_new_pack.5fOz2d/_new 2017-04-11 09:32:05.547865216 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-json-schema # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-json-schema -Version: 2.7.0 +Version: 2.8.0 Release: 0 %define mod_name json-schema %define mod_full_name %{mod_name}-%{version} ++++++ json-schema-2.7.0.gem -> json-schema-2.8.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2016-09-29 15:26:19.000000000 +0200 +++ new/README.md 2017-02-07 11:35:47.000000000 +0100 @@ -1,3 +1,4 @@ +[![Gem Version](https://badge.fury.io/rb/json-schema.svg)](https://badge.fury.io/rb/json-schema) [![Travis](https://travis-ci.org/ruby-json-schema/json-schema.svg?branch=master)](https://travis-ci.org/ruby-json-schema/json-schema) [![Code Climate](https://codeclimate.com/github/ruby-json-schema/json-schema/badges/gpa.svg)](https://codeclimate.com/github/ruby-json-schema/json-schema) @@ -290,17 +291,17 @@ def self.validate(current_schema, data, fragments, processor, validator, options = {}) if data.is_a?(Integer) && data & current_schema.schema['bitwise-and'].to_i == 0 message = "The property '#{build_fragment(fragments)}' did not evaluate to true when bitwise-AND'd with #{current_schema.schema['bitwise-or']}" - raise JSON::Schema::ValidationError.new(message, fragments, current_schema) + validation_error(processor, message, fragments, current_schema, self, options[:record_errors]) end end end -class ExtendedSchema < JSON::Schema::Validator +class ExtendedSchema < JSON::Schema::Draft3 def initialize super - extend_schema_definition("http://json-schema.org/draft-03/schema#") @attributes["bitwise-and"] = BitwiseAndAttribute - @uri = URI.parse("http://test.com/test.json") + @uri = JSON::Util::URI.parse("http://test.com/test.json") + @names = ["http://test.com/test.json"] end JSON::Validator.register_validator(self.new) Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/attribute.rb new/lib/json-schema/attribute.rb --- old/lib/json-schema/attribute.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/attribute.rb 2017-02-07 11:35:47.000000000 +0100 @@ -38,6 +38,16 @@ valid_classes = TYPE_CLASS_MAPPINGS.fetch(type) { return true } Array(valid_classes).any? { |c| data.is_a?(c) } end + + # Lookup Schema type of given class instance + def self.type_of_data(data) + type, _ = TYPE_CLASS_MAPPINGS.map { |k,v| [k,v] }.sort_by { |(_, v)| + -Array(v).map { |klass| klass.ancestors.size }.max + }.find { |(_, v)| + Array(v).any? { |klass| data.kind_of?(klass) } + } + type + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/attributes/allof.rb new/lib/json-schema/attributes/allof.rb --- old/lib/json-schema/attributes/allof.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/attributes/allof.rb 2017-02-07 11:35:47.000000000 +0100 @@ -29,7 +29,7 @@ end if !valid || !errors.empty? - message = "The property '#{build_fragment(fragments)}' of type #{data.class} did not match all of the required schemas" + message = "The property '#{build_fragment(fragments)}' of type #{type_of_data(data)} did not match all of the required schemas" validation_error(processor, message, fragments, current_schema, self, options[:record_errors]) validation_errors(processor).last.sub_errors = errors end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/attributes/anyof.rb new/lib/json-schema/attributes/anyof.rb --- old/lib/json-schema/attributes/anyof.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/attributes/anyof.rb 2017-02-07 11:35:47.000000000 +0100 @@ -37,7 +37,7 @@ end if !valid - message = "The property '#{build_fragment(fragments)}' of type #{data.class} did not match one or more of the required schemas" + message = "The property '#{build_fragment(fragments)}' of type #{type_of_data(data)} did not match one or more of the required schemas" validation_error(processor, message, fragments, current_schema, self, options[:record_errors]) validation_errors(processor).last.sub_errors = errors end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/attributes/not.rb new/lib/json-schema/attributes/not.rb --- old/lib/json-schema/attributes/not.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/attributes/not.rb 2017-02-07 11:35:47.000000000 +0100 @@ -14,7 +14,7 @@ if options[:record_errors] && errors_copy.length != processor.validation_errors.length processor.validation_errors.replace(errors_copy) else - message = "The property '#{build_fragment(fragments)}' of type #{data.class} matched the disallowed schema" + message = "The property '#{build_fragment(fragments)}' of type #{type_of_data(data)} matched the disallowed schema" failed = false end rescue ValidationError diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/attributes/oneof.rb new/lib/json-schema/attributes/oneof.rb --- old/lib/json-schema/attributes/oneof.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/attributes/oneof.rb 2017-02-07 11:35:47.000000000 +0100 @@ -43,9 +43,9 @@ end if validation_error_count == one_of.length - message = "The property '#{build_fragment(fragments)}' of type #{data.class} did not match any of the required schemas" + message = "The property '#{build_fragment(fragments)}' of type #{type_of_data(data)} did not match any of the required schemas" else - message = "The property '#{build_fragment(fragments)}' of type #{data.class} matched more than one of the required schemas" + message = "The property '#{build_fragment(fragments)}' of type #{type_of_data(data)} matched more than one of the required schemas" end validation_error(processor, message, fragments, current_schema, self, options[:record_errors]) if message diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/attributes/ref.rb new/lib/json-schema/attributes/ref.rb --- old/lib/json-schema/attributes/ref.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/attributes/ref.rb 2017-02-07 11:35:47.000000000 +0100 @@ -22,23 +22,7 @@ def self.get_referenced_uri_and_schema(s, current_schema, validator) uri,schema = nil,nil - temp_uri = JSON::Util::URI.parse(s['$ref']) - temp_uri.defer_validation do - if temp_uri.relative? - temp_uri.merge!(current_schema.uri) - # Check for absolute path - path, fragment = s['$ref'].split("#") - if path.nil? || path == '' - temp_uri.path = current_schema.uri.path - elsif path[0,1] == "/" - temp_uri.path = Pathname.new(path).cleanpath.to_s - else - temp_uri.join!(path) - end - temp_uri.fragment = fragment - end - temp_uri.fragment = "" if temp_uri.fragment.nil? || temp_uri.fragment.empty? - end + temp_uri = JSON::Util::URI.normalize_ref(s['$ref'], current_schema.uri) # Grab the parent schema from the schema list schema_key = temp_uri.to_s.split("#")[0] + "#" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/attributes/type.rb new/lib/json-schema/attributes/type.rb --- old/lib/json-schema/attributes/type.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/attributes/type.rb 2017-02-07 11:35:47.000000000 +0100 @@ -68,16 +68,6 @@ def self.list_types(types) types.map { |type| type.is_a?(String) ? type : '(schema)' }.join(', ') end - - # Lookup Schema type of given class instance - def self.type_of_data(data) - type, _ = TYPE_CLASS_MAPPINGS.map { |k,v| [k,v] }.sort_by { |(_, v)| - -Array(v).map { |klass| klass.ancestors.size }.max - }.find { |(_, v)| - Array(v).any? { |klass| data.kind_of?(klass) } - } - type - end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/attributes/type_v4.rb new/lib/json-schema/attributes/type_v4.rb --- old/lib/json-schema/attributes/type_v4.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/attributes/type_v4.rb 2017-02-07 11:35:47.000000000 +0100 @@ -17,7 +17,7 @@ message = format( "The property '%s' of type %s did not match %s: %s", build_fragment(fragments), - data.class, + type_of_data(data), union ? 'one or more of the following types' : 'the following type', types ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/schema/validator.rb new/lib/json-schema/schema/validator.rb --- old/lib/json-schema/schema/validator.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/schema/validator.rb 2017-02-07 11:35:47.000000000 +0100 @@ -14,7 +14,8 @@ end def extend_schema_definition(schema_uri) - validator = JSON::Validator.validator_for(schema_uri) + warn "[DEPRECATION NOTICE] The preferred way to extend a Validator is by subclassing, rather than #extend_schema_definition. This method will be removed in version >= 3." + validator = JSON::Validator.validator_for_uri(schema_uri) @attributes.merge!(validator.attributes) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/schema.rb new/lib/json-schema/schema.rb --- old/lib/json-schema/schema.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/schema.rb 2017-02-07 11:35:47.000000000 +0100 @@ -21,7 +21,7 @@ # If there is a $schema on this schema, use it to determine which validator to use if @schema['$schema'] - @validator = JSON::Validator.validator_for(@schema['$schema']) + @validator = JSON::Validator.validator_for_uri(@schema['$schema']) elsif parent_validator @validator = parent_validator else @@ -52,7 +52,7 @@ def to_array_schema array_schema = { 'type' => 'array', 'items' => schema } array_schema['$schema'] = schema['$schema'] unless schema['$schema'].nil? - JSON::Schema.new(array_schema, uri, validator) + self.class.new(array_schema, uri, validator) end def to_s diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/util/array_set.rb new/lib/json-schema/util/array_set.rb --- old/lib/json-schema/util/array_set.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/util/array_set.rb 2017-02-07 11:35:47.000000000 +0100 @@ -7,14 +7,14 @@ def include?(obj) if !defined? @values @values = Set.new - self.each { |x| @values << convert_to_float_if_fixnum(x) } + self.each { |x| @values << convert_to_float_if_numeric(x) } end - @values.include?(convert_to_float_if_fixnum(obj)) + @values.include?(convert_to_float_if_numeric(obj)) end private - def convert_to_float_if_fixnum(value) - value.is_a?(Fixnum) ? value.to_f : value + def convert_to_float_if_numeric(value) + value.is_a?(Numeric) ? value.to_f : value end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/util/uri.rb new/lib/json-schema/util/uri.rb --- old/lib/json-schema/util/uri.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/util/uri.rb 2017-02-07 11:35:47.000000000 +0100 @@ -23,6 +23,43 @@ normalized_uri end + def self.absolutize_ref(ref, base) + ref_uri = strip_fragment(ref.dup) + + return ref_uri if ref_uri.absolute? + return parse(base) if ref_uri.path.empty? + + uri = strip_fragment(base.dup).join(ref_uri.path) + normalized_uri(uri) + end + + def self.normalize_ref(ref, base) + ref_uri = parse(ref) + base_uri = parse(base) + + ref_uri.defer_validation do + if ref_uri.relative? + ref_uri.merge!(base_uri) + + # Check for absolute path + path, fragment = ref.to_s.split("#") + if path.nil? || path == '' + ref_uri.path = base_uri.path + elsif path[0,1] == "/" + ref_uri.path = Pathname.new(path).cleanpath.to_s + else + ref_uri.join!(path) + end + + ref_uri.fragment = fragment + end + + ref_uri.fragment = "" if ref_uri.fragment.nil? || ref_uri.fragment.empty? + end + + ref_uri + end + def self.parse(uri) if uri.is_a?(Addressable::URI) return uri.dup @@ -63,6 +100,11 @@ Addressable::URI.unescape(parsed_uri.path) end + + def self.clear_cache + @parse_cache = {} + @normalize_cache = {} + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/util/uuid.rb new/lib/json-schema/util/uuid.rb --- old/lib/json-schema/util/uuid.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/util/uuid.rb 2017-02-07 11:35:47.000000000 +0100 @@ -241,7 +241,6 @@ alias urn to_uri # Convert into 128-bit unsigned integer - # Typically a Bignum instance, but can be a Fixnum. def to_int tmp = self.raw_bytes.unpack "C*" tmp.inject do |r, i| diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/validator.rb new/lib/json-schema/validator.rb --- old/lib/json-schema/validator.rb 2016-09-29 15:26:19.000000000 +0200 +++ new/lib/json-schema/validator.rb 2017-02-07 11:35:47.000000000 +0100 @@ -41,9 +41,9 @@ @options = @@default_opts.clone.merge(opts) @errors = [] - validator = JSON::Validator.validator_for_name(@options[:version]) + validator = self.class.validator_for_name(@options[:version]) @options[:version] = validator - @options[:schema_reader] ||= JSON::Validator.schema_reader + @options[:schema_reader] ||= self.class.schema_reader @validation_options = @options[:record_errors] ? {:record_errors => true} : {} @validation_options[:insert_defaults] = true if @options[:insert_defaults] @@ -58,7 +58,7 @@ # validate the schema, if requested if @options[:validate_schema] if @base_schema.schema["$schema"] - base_validator = JSON::Validator.validator_for_name(@base_schema.schema["$schema"]) + base_validator = self.class.validator_for_name(@base_schema.schema["$schema"]) end metaschema = base_validator ? base_validator.metaschema : validator.metaschema # Don't clear the cache during metaschema validation! @@ -123,33 +123,25 @@ end ensure if @validation_options[:clear_cache] == true - Validator.clear_cache + self.class.clear_cache end if @validation_options[:insert_defaults] - JSON::Validator.merge_missing_values(@data, @original_data) + self.class.merge_missing_values(@data, @original_data) end end def load_ref_schema(parent_schema, ref) - schema_uri = absolutize_ref_uri(ref, parent_schema.uri) + schema_uri = JSON::Util::URI.absolutize_ref(ref, parent_schema.uri) return true if self.class.schema_loaded?(schema_uri) + validator = self.class.validator_for_uri(schema_uri, false) + schema_uri = JSON::Util::URI.file_uri(validator.metaschema) if validator + schema = @options[:schema_reader].read(schema_uri) self.class.add_schema(schema) build_schemas(schema) end - def absolutize_ref_uri(ref, parent_schema_uri) - ref_uri = JSON::Util::URI.strip_fragment(ref) - - return ref_uri if ref_uri.absolute? - # This is a self reference and thus the schema does not need to be re-loaded - return parent_schema_uri if ref_uri.path.empty? - - uri = JSON::Util::URI.strip_fragment(parent_schema_uri.dup) - Util::URI.normalized_uri(uri.join(ref_uri.path)) - end - # Build all schemas with IDs, mapping out the namespace def build_schemas(parent_schema) schema = parent_schema.schema @@ -225,7 +217,7 @@ schema_uri = parent_schema.uri.dup schema = JSON::Schema.new(obj, schema_uri, parent_schema.validator) if obj['id'] - Validator.add_schema(schema) + self.class.add_schema(schema) end build_schemas(schema) end @@ -258,10 +250,14 @@ end def validate!(schema, data,opts={}) - validator = JSON::Validator.new(schema, data, opts) + validator = new(schema, data, opts) validator.validate end - alias_method 'validate2', 'validate!' + + def validate2(schema, data, opts={}) + warn "[DEPRECATION NOTICE] JSON::Validator#validate2 has been replaced by JSON::Validator#validate! and will be removed in version >= 3. Please use the #validate! method instead." + validate!(schema, data, opts) + end def validate_json!(schema, data, opts={}) validate!(schema, data, opts.merge(:json => true)) @@ -277,7 +273,7 @@ def fully_validate_schema(schema, opts={}) data = schema - schema = JSON::Validator.validator_for_name(opts[:version]).metaschema + schema = validator_for_name(opts[:version]).metaschema fully_validate(schema, data, opts) end @@ -299,6 +295,7 @@ def clear_cache @@schemas = {} + JSON::Util::URI.clear_cache end def schemas @@ -337,28 +334,34 @@ @@default_validator end - def validator_for_uri(schema_uri) + def validator_for_uri(schema_uri, raise_not_found=true) return default_validator unless schema_uri u = JSON::Util::URI.parse(schema_uri) validator = validators["#{u.scheme}://#{u.host}#{u.path}"] - if validator.nil? + if validator.nil? && raise_not_found raise JSON::Schema::SchemaError.new("Schema not found: #{schema_uri}") else validator end end - def validator_for_name(schema_name) + def validator_for_name(schema_name, raise_not_found=true) return default_validator unless schema_name - validator = validators_for_names([schema_name]).first - if validator.nil? + schema_name = schema_name.to_s + validator = validators.values.detect do |v| + Array(v.names).include?(schema_name) + end + if validator.nil? && raise_not_found raise JSON::Schema::SchemaError.new("The requested JSON schema version is not supported") else validator end end - alias_method :validator_for, :validator_for_uri + def validator_for(schema_uri) + warn "[DEPRECATION NOTICE] JSON::Validator#validator_for has been replaced by JSON::Validator#validator_for_uri and will be removed in version >= 3. Please use the #validator_for_uri method instead." + validator_for_uri(schema_uri) + end def register_validator(v) @@validators["#{v.uri.scheme}://#{v.uri.host}#{v.uri.path}"] = v @@ -368,21 +371,24 @@ @@default_validator = v end - def register_format_validator(format, validation_proc, versions = ["draft1", "draft2", "draft3", "draft4", nil]) + def register_format_validator(format, validation_proc, versions = (@@validators.flat_map{ |k, v| v.names.first } + [nil])) custom_format_validator = JSON::Schema::CustomFormat.new(validation_proc) - validators_for_names(versions).each do |validator| + versions.each do |version| + validator = validator_for_name(version) validator.formats[format.to_s] = custom_format_validator end end - def deregister_format_validator(format, versions = ["draft1", "draft2", "draft3", "draft4", nil]) - validators_for_names(versions).each do |validator| + def deregister_format_validator(format, versions = (@@validators.flat_map{ |k, v| v.names.first } + [nil])) + versions.each do |version| + validator = validator_for_name(version) validator.formats[format.to_s] = validator.default_formats[format.to_s] end end - def restore_default_formats(versions = ["draft1", "draft2", "draft3", "draft4", nil]) - validators_for_names(versions).each do |validator| + def restore_default_formats(versions = (@@validators.flat_map{ |k, v| v.names.first } + [nil])) + versions.each do |version| + validator = validator_for_name(version) validator.formats = validator.default_formats.clone end end @@ -487,22 +493,6 @@ @@serializer = lambda{|o| YAML.dump(o) } end end - - private - - def validators_for_names(names) - names = names.map { |name| name.to_s } - [].tap do |memo| - validators.each do |_, validator| - if (validator.names & names).any? - memo << validator - end - end - if names.include?('') - memo << default_validator - end - end - end end private @@ -532,11 +522,11 @@ begin # Build a fake URI for this schema_uri = JSON::Util::URI.parse(fake_uuid(schema)) - schema = JSON::Schema.new(JSON::Validator.parse(schema), schema_uri, @options[:version]) + schema = JSON::Schema.new(self.class.parse(schema), schema_uri, @options[:version]) if @options[:list] && @options[:fragment].nil? schema = schema.to_array_schema end - Validator.add_schema(schema) + self.class.add_schema(schema) rescue JSON::Schema::JsonParseError # Build a uri for it schema_uri = Util::URI.normalized_uri(schema) @@ -548,13 +538,13 @@ schema = schema.to_array_schema end - Validator.add_schema(schema) + self.class.add_schema(schema) else schema = self.class.schema_for_uri(schema_uri) if @options[:list] && @options[:fragment].nil? schema = schema.to_array_schema schema.uri = JSON::Util::URI.parse(fake_uuid(serialize(schema.schema))) - Validator.add_schema(schema) + self.class.add_schema(schema) end schema end @@ -566,7 +556,7 @@ if @options[:list] && @options[:fragment].nil? schema = schema.to_array_schema end - Validator.add_schema(schema) + self.class.add_schema(schema) else raise JSON::Schema::SchemaParseError, "Invalid schema - must be either a string or a hash" end @@ -577,17 +567,17 @@ def initialize_data(data) if @options[:parse_data] if @options[:json] - data = JSON::Validator.parse(data) + data = self.class.parse(data) elsif @options[:uri] json_uri = Util::URI.normalized_uri(data) - data = JSON::Validator.parse(custom_open(json_uri)) + data = self.class.parse(custom_open(json_uri)) elsif data.is_a?(String) begin - data = JSON::Validator.parse(data) + data = self.class.parse(data) rescue JSON::Schema::JsonParseError begin json_uri = Util::URI.normalized_uri(data) - data = JSON::Validator.parse(custom_open(json_uri)) + data = self.class.parse(custom_open(json_uri)) rescue JSON::Schema::JsonLoadError # Silently discard the error - use the data as-is end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/validators/draft6.rb new/lib/json-schema/validators/draft6.rb --- old/lib/json-schema/validators/draft6.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/json-schema/validators/draft6.rb 2017-02-07 11:35:47.000000000 +0100 @@ -0,0 +1,56 @@ +require 'json-schema/schema/validator' + +module JSON + class Schema + + class Draft6 < Validator + def initialize + super + @attributes = { + "type" => JSON::Schema::TypeV4Attribute, + "allOf" => JSON::Schema::AllOfAttribute, + "anyOf" => JSON::Schema::AnyOfAttribute, + "oneOf" => JSON::Schema::OneOfAttribute, + "not" => JSON::Schema::NotAttribute, + "disallow" => JSON::Schema::DisallowAttribute, + "format" => JSON::Schema::FormatAttribute, + "maximum" => JSON::Schema::MaximumAttribute, + "minimum" => JSON::Schema::MinimumAttribute, + "minItems" => JSON::Schema::MinItemsAttribute, + "maxItems" => JSON::Schema::MaxItemsAttribute, + "minProperties" => JSON::Schema::MinPropertiesAttribute, + "maxProperties" => JSON::Schema::MaxPropertiesAttribute, + "uniqueItems" => JSON::Schema::UniqueItemsAttribute, + "minLength" => JSON::Schema::MinLengthAttribute, + "maxLength" => JSON::Schema::MaxLengthAttribute, + "multipleOf" => JSON::Schema::MultipleOfAttribute, + "enum" => JSON::Schema::EnumAttribute, + "properties" => JSON::Schema::PropertiesV4Attribute, + "required" => JSON::Schema::RequiredAttribute, + "pattern" => JSON::Schema::PatternAttribute, + "patternProperties" => JSON::Schema::PatternPropertiesAttribute, + "additionalProperties" => JSON::Schema::AdditionalPropertiesAttribute, + "items" => JSON::Schema::ItemsAttribute, + "additionalItems" => JSON::Schema::AdditionalItemsAttribute, + "dependencies" => JSON::Schema::DependenciesV4Attribute, + "extends" => JSON::Schema::ExtendsAttribute, + "$ref" => JSON::Schema::RefAttribute + } + @default_formats = { + 'date-time' => DateTimeV4Format, + 'ipv4' => IP4Format, + 'ipv6' => IP6Format, + 'uri' => UriFormat + } + @formats = @default_formats.clone + @uri = JSON::Util::URI.parse("http://json-schema.org/draft-06/schema#") + @names = ["draft6", "http://json-schema.org/draft-06/schema#"] + @metaschema_name = "draft-06.json" + end + + JSON::Validator.register_validator(self.new) + JSON::Validator.register_default_validator(self.new) + end + + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/validators/hyper-draft3.rb new/lib/json-schema/validators/hyper-draft3.rb --- old/lib/json-schema/validators/hyper-draft3.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/json-schema/validators/hyper-draft3.rb 2017-02-07 11:35:47.000000000 +0100 @@ -0,0 +1,13 @@ +module JSON + class Schema + + class HyperDraft3 < Draft3 + def initialize + super + @uri = JSON::Util::URI.parse("http://json-schema.org/draft-03/hyper-schema#") + end + + JSON::Validator.register_validator(self.new) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/json-schema/validators/hyper-draft6.rb new/lib/json-schema/validators/hyper-draft6.rb --- old/lib/json-schema/validators/hyper-draft6.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/json-schema/validators/hyper-draft6.rb 2017-02-07 11:35:47.000000000 +0100 @@ -0,0 +1,13 @@ +module JSON + class Schema + + class HyperDraft6 < Draft6 + def initialize + super + @uri = JSON::Util::URI.parse("http://json-schema.org/draft-06/hyper-schema#") + end + + JSON::Validator.register_validator(self.new) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-09-29 15:26:19.000000000 +0200 +++ new/metadata 2017-02-07 11:35:47.000000000 +0100 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: json-schema version: !ruby/object:Gem::Version - version: 2.7.0 + version: 2.8.0 platform: ruby authors: - Kenny Hoxworth autorequire: bindir: bin cert_chain: [] -date: 2016-09-29 00:00:00.000000000 Z +date: 2017-02-07 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rake @@ -142,13 +142,17 @@ - lib/json-schema/validators/draft2.rb - lib/json-schema/validators/draft3.rb - lib/json-schema/validators/draft4.rb +- lib/json-schema/validators/draft6.rb - lib/json-schema/validators/hyper-draft1.rb - lib/json-schema/validators/hyper-draft2.rb +- lib/json-schema/validators/hyper-draft3.rb - lib/json-schema/validators/hyper-draft4.rb +- lib/json-schema/validators/hyper-draft6.rb - resources/draft-01.json - resources/draft-02.json - resources/draft-03.json - resources/draft-04.json +- resources/draft-06.json homepage: http://github.com/ruby-json-schema/json-schema/tree/master licenses: - MIT @@ -169,7 +173,7 @@ version: '1.8' requirements: [] rubyforge_project: -rubygems_version: 2.5.1 +rubygems_version: 2.6.8 signing_key: specification_version: 4 summary: Ruby JSON Schema Validator diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resources/draft-03.json new/resources/draft-03.json --- old/resources/draft-03.json 2016-09-29 15:26:19.000000000 +0200 +++ new/resources/draft-03.json 2017-02-07 11:35:47.000000000 +0100 @@ -1,174 +1,174 @@ { - "$schema" : "http://json-schema.org/draft-03/schema#", - "id" : "http://json-schema.org/draft-03/schema#", - "type" : "object", - - "properties" : { - "type" : { - "type" : ["string", "array"], - "items" : { - "type" : ["string", {"$ref" : "#"}] - }, - "uniqueItems" : true, - "default" : "any" - }, - - "properties" : { - "type" : "object", - "additionalProperties" : {"$ref" : "#"}, - "default" : {} - }, - - "patternProperties" : { - "type" : "object", - "additionalProperties" : {"$ref" : "#"}, - "default" : {} - }, - - "additionalProperties" : { - "type" : [{"$ref" : "#"}, "boolean"], - "default" : {} - }, - - "items" : { - "type" : [{"$ref" : "#"}, "array"], - "items" : {"$ref" : "#"}, - "default" : {} - }, - - "additionalItems" : { - "type" : [{"$ref" : "#"}, "boolean"], - "default" : {} - }, - - "required" : { - "type" : "boolean", - "default" : false - }, - - "dependencies" : { - "type" : "object", - "additionalProperties" : { - "type" : ["string", "array", {"$ref" : "#"}], - "items" : { - "type" : "string" - } - }, - "default" : {} - }, - - "minimum" : { - "type" : "number" - }, - - "maximum" : { - "type" : "number" - }, - - "exclusiveMinimum" : { - "type" : "boolean", - "default" : false - }, - - "exclusiveMaximum" : { - "type" : "boolean", - "default" : false - }, - - "minItems" : { - "type" : "integer", - "minimum" : 0, - "default" : 0 - }, - - "maxItems" : { - "type" : "integer", - "minimum" : 0 - }, - - "uniqueItems" : { - "type" : "boolean", - "default" : false - }, - - "pattern" : { - "type" : "string", - "format" : "regex" - }, - - "minLength" : { - "type" : "integer", - "minimum" : 0, - "default" : 0 - }, - - "maxLength" : { - "type" : "integer" - }, - - "enum" : { - "type" : "array", - "minItems" : 1, - "uniqueItems" : true - }, - - "default" : { - "type" : "any" - }, - - "title" : { - "type" : "string" - }, - - "description" : { - "type" : "string" - }, - - "format" : { - "type" : "string" - }, - - "divisibleBy" : { - "type" : "number", - "minimum" : 0, - "exclusiveMinimum" : true, - "default" : 1 - }, - - "disallow" : { - "type" : ["string", "array"], - "items" : { - "type" : ["string", {"$ref" : "#"}] - }, - "uniqueItems" : true - }, - - "extends" : { - "type" : [{"$ref" : "#"}, "array"], - "items" : {"$ref" : "#"}, - "default" : {} - }, - - "id" : { - "type" : "string", - "format" : "uri" - }, - - "$ref" : { - "type" : "string", - "format" : "uri" - }, - - "$schema" : { - "type" : "string", - "format" : "uri" - } - }, - - "dependencies" : { - "exclusiveMinimum" : "minimum", - "exclusiveMaximum" : "maximum" - }, - - "default" : {} -} \ No newline at end of file + "$schema": "http://json-schema.org/draft-03/schema#", + "id": "http://json-schema.org/draft-03/schema#", + "type": "object", + + "properties": { + "type": { + "type": [ "string", "array" ], + "items": { + "type": [ "string", { "$ref": "#" } ] + }, + "uniqueItems": true, + "default": "any" + }, + + "properties": { + "type": "object", + "additionalProperties": { "$ref": "#" }, + "default": {} + }, + + "patternProperties": { + "type": "object", + "additionalProperties": { "$ref": "#" }, + "default": {} + }, + + "additionalProperties": { + "type": [ { "$ref": "#" }, "boolean" ], + "default": {} + }, + + "items": { + "type": [ { "$ref": "#" }, "array" ], + "items": { "$ref": "#" }, + "default": {} + }, + + "additionalItems": { + "type": [ { "$ref": "#" }, "boolean" ], + "default": {} + }, + + "required": { + "type": "boolean", + "default": false + }, + + "dependencies": { + "type": "object", + "additionalProperties": { + "type": [ "string", "array", { "$ref": "#" } ], + "items": { + "type": "string" + } + }, + "default": {} + }, + + "minimum": { + "type": "number" + }, + + "maximum": { + "type": "number" + }, + + "exclusiveMinimum": { + "type": "boolean", + "default": false + }, + + "exclusiveMaximum": { + "type": "boolean", + "default": false + }, + + "minItems": { + "type": "integer", + "minimum": 0, + "default": 0 + }, + + "maxItems": { + "type": "integer", + "minimum": 0 + }, + + "uniqueItems": { + "type": "boolean", + "default": false + }, + + "pattern": { + "type": "string", + "format": "regex" + }, + + "minLength": { + "type": "integer", + "minimum": 0, + "default": 0 + }, + + "maxLength": { + "type": "integer" + }, + + "enum": { + "type": "array", + "minItems": 1, + "uniqueItems": true + }, + + "default": { + "type": "any" + }, + + "title": { + "type": "string" + }, + + "description": { + "type": "string" + }, + + "format": { + "type": "string" + }, + + "divisibleBy": { + "type": "number", + "minimum": 0, + "exclusiveMinimum": true, + "default": 1 + }, + + "disallow": { + "type": [ "string", "array" ], + "items": { + "type": [ "string", { "$ref": "#" } ] + }, + "uniqueItems": true + }, + + "extends": { + "type": [ { "$ref": "#" }, "array" ], + "items": { "$ref": "#" }, + "default": {} + }, + + "id": { + "type": "string", + "format": "uri" + }, + + "$ref": { + "type": "string", + "format": "uri" + }, + + "$schema": { + "type": "string", + "format": "uri" + } + }, + + "dependencies": { + "exclusiveMinimum": "minimum", + "exclusiveMaximum": "maximum" + }, + + "default": {} +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/resources/draft-06.json new/resources/draft-06.json --- old/resources/draft-06.json 1970-01-01 01:00:00.000000000 +0100 +++ new/resources/draft-06.json 2017-02-07 11:35:47.000000000 +0100 @@ -0,0 +1,150 @@ +{ + "id": "http://json-schema.org/draft-06/schema#", + "$schema": "http://json-schema.org/draft-06/schema#", + "description": "Core schema meta-schema", + "definitions": { + "schemaArray": { + "type": "array", + "minItems": 1, + "items": { "$ref": "#" } + }, + "positiveInteger": { + "type": "integer", + "minimum": 0 + }, + "positiveIntegerDefault0": { + "allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ] + }, + "simpleTypes": { + "enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ] + }, + "stringArray": { + "type": "array", + "items": { "type": "string" }, + "minItems": 1, + "uniqueItems": true + } + }, + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uri" + }, + "$schema": { + "type": "string", + "format": "uri" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "default": {}, + "multipleOf": { + "type": "number", + "minimum": 0, + "exclusiveMinimum": true + }, + "maximum": { + "type": "number" + }, + "exclusiveMaximum": { + "type": "boolean", + "default": false + }, + "minimum": { + "type": "number" + }, + "exclusiveMinimum": { + "type": "boolean", + "default": false + }, + "maxLength": { "$ref": "#/definitions/positiveInteger" }, + "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" }, + "pattern": { + "type": "string", + "format": "regex" + }, + "additionalItems": { + "anyOf": [ + { "type": "boolean" }, + { "$ref": "#" } + ], + "default": {} + }, + "items": { + "anyOf": [ + { "$ref": "#" }, + { "$ref": "#/definitions/schemaArray" } + ], + "default": {} + }, + "maxItems": { "$ref": "#/definitions/positiveInteger" }, + "minItems": { "$ref": "#/definitions/positiveIntegerDefault0" }, + "uniqueItems": { + "type": "boolean", + "default": false + }, + "maxProperties": { "$ref": "#/definitions/positiveInteger" }, + "minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" }, + "required": { "$ref": "#/definitions/stringArray" }, + "additionalProperties": { + "anyOf": [ + { "type": "boolean" }, + { "$ref": "#" } + ], + "default": {} + }, + "definitions": { + "type": "object", + "additionalProperties": { "$ref": "#" }, + "default": {} + }, + "properties": { + "type": "object", + "additionalProperties": { "$ref": "#" }, + "default": {} + }, + "patternProperties": { + "type": "object", + "additionalProperties": { "$ref": "#" }, + "default": {} + }, + "dependencies": { + "type": "object", + "additionalProperties": { + "anyOf": [ + { "$ref": "#" }, + { "$ref": "#/definitions/stringArray" } + ] + } + }, + "enum": { + "type": "array", + "minItems": 1, + "uniqueItems": true + }, + "type": { + "anyOf": [ + { "$ref": "#/definitions/simpleTypes" }, + { + "type": "array", + "items": { "$ref": "#/definitions/simpleTypes" }, + "minItems": 1, + "uniqueItems": true + } + ] + }, + "allOf": { "$ref": "#/definitions/schemaArray" }, + "anyOf": { "$ref": "#/definitions/schemaArray" }, + "oneOf": { "$ref": "#/definitions/schemaArray" }, + "not": { "$ref": "#" } + }, + "dependencies": { + "exclusiveMaximum": [ "maximum" ], + "exclusiveMinimum": [ "minimum" ] + }, + "default": {} +}