voxpupuli / json-schema

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

Unexpected token error parsing URI for metaschema (I think) #326

Open aviflax opened 8 years ago

aviflax commented 8 years ago

My setup is pretty strange so I understand if this is too obscure to troubleshoot.

I’m writing an app using JRuby (9.1.0.0) that uses a Maven plugin to package all the gems together into a… package. I think they get wrapped up into a jar file.

At runtime, I have a module with these two constants:

# Access resources on the classpath by prefixing the path with the scheme `classpath`
JSON_SCHEMA_PATH = 'classpath:/schemata/bay_event/bay_event_from_park_server.json'.freeze
JSON_SCHEMA = JSON.parse(File.read(JSON_SCHEMA_PATH)).freeze

… which works just fine.

Then I call the validator:

validation_errors = JSON::Validator.fully_validate schema, event,
                                                   validate_schema: true, insert_defaults: true

which also works fine.

The issue I’m having — which isn’t major, I think — is that I just happened to be running this app locally with Ruby’s “debug mode” enabled, wherein apparently (I’m new to Ruby) the interpreter will print out exceptions that are caught but don’t quite bubble up? (I’m a little confused as to why I’m seeing these actually. Maybe because the validation is running in a child thread… maybe the thread is dying but I can’t tell.) Anyway I’m seeing many of these messages in my console:

Exception `JSON::Schema::JsonParseError' at uri:classloader:/gems/json-schema-2.6.0/lib/json-schema/validator.rb:426 - unexpected token at 'uri:classloader://gems/json-schema-2.6.0/resources/draft-04.json'

I can’t catch these exceptions, so I guess they’re being caught somewhere within the validator.

So, a few questions:

Thanks for reading all this!