json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

JSON::Schema::SchemaError: Schema not found

Open mwpastore opened this issue 9 years ago • 3 comments

I'm trying to validate a JSON payload that should conform to this schema but I can't get past this error:

#<JSON::Schema::SchemaError: Schema not found: http://json-schema.org/schema#>

I feel like I've tried everything but I must be missing something. I tried to tweak JSON::Validator.schema_reader so it would accept a URI and fetch the document from the Internet. I also tried staging the schema on disk ahead of time, parsing it, and adding it with JSON::Validator.add_schema and the http://json-schema.org/schema# URL. I've tried with/without :strict, :validate_schema, :json, etc. Any suggestions?

mwpastore avatar Nov 19 '15 23:11 mwpastore

It seems support for version 1.0 final of the spec isn't ready yet, try with the default version of the spec, which is "$schema": "http://json-schema.org/draft-04/schema#". I've tried with both and got the same error as you with the final 1.0 version of the spec; the last draft worked properly though.

bdusauso avatar Nov 25 '15 14:11 bdusauso

I get the same error when using http://interagent.github.io/interagent-hyper-schema#. Is it actually fetching the schema from the Internet, or just locally?

aledalgrande avatar May 21 '16 02:05 aledalgrande

I had the same problem, but turns out it was related to a custom extension that didn't have a properly registered validator to it's url. The error description was misleading on validator.rb:346. It's looking for a validator for a given uri and when that validator is not found it raises a Schema not found error.

If any of you are using schema extensions, I think checking this is worth a shot.

angelim avatar May 31 '16 06:05 angelim