voxpupuli / json-schema

Ruby JSON Schema Validator
MIT License
1.52k stars 242 forks source link

Uninitialized constant JSON::Validator::Timeout #384

Closed Samze closed 2 years ago

Samze commented 7 years ago

When running the following code, I get the following exception uninitialized constant JSON::Validator::Timeout Did you mean? Time

Reproduce:

require 'json-schema'
require 'json'

begin
  file = File.read(JSON::Validator.validator_for_name('draft4').metaschema)
  metaschema = JSON.parse(file)

  JSON::Validator.schema_reader = JSON::Schema::Reader.new(:accept_uri => false, :accept_file => false)
  valid = JSON::Validator.validate(metaschema, "http://a/%%30%30")
rescue => e
  puts e
end

Stacktrace

 ["/Users/pivotal/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/json-schema-2.8.0/lib/json-schema/validator.rb:595:in `rescue in custom_open'",
 "/Users/pivotal/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/json-schema-2.8.0/lib/json-schema/validator.rb:593:in `custom_open'",
 "/Users/pivotal/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/json-schema-2.8.0/lib/json-schema/validator.rb:580:in `rescue in initialize_data'",
 "/Users/pivotal/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/json-schema-2.8.0/lib/json-schema/validator.rb:575:in `initialize_data'",
 "/Users/pivotal/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/json-schema-2.8.0/lib/json-schema/validator.rb:55:in `initialize'",
 "/Users/pivotal/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/json-schema-2.8.0/lib/json-schema/validator.rb:253:in `new'",
 "/Users/pivotal/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/json-schema-2.8.0/lib/json-schema/validator.rb:253:in `validate!'",
 "/Users/pivotal/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/json-schema-2.8.0/lib/json-schema/validator.rb:238:in `validate'",
 "test.rb:16:in `<main>'"]

Thanks, Sam & @ablease

iainbeeston commented 7 years ago

I've just made a fix for that in #385 - do you think you could try updating your Gemfile to use github: 'iainbeeston/json-schema, branch: 'absolute-class-for-timeout' and tell me if that fixes the issue for you?

Samze commented 6 years ago

Thanks for the quick response and sorry for my delayed one.

Yes this worked. Thank you