Open panSarin opened 8 years ago
I forked and debugged. It seems like it will never find file basing on json pointer, until you pass '.json' in pointer. But in JSON pointers we shouldn't pass it. Is it a bug , or I am still doing something wrong?
Ok i think my question should be : can we use hyper-schema in JSON::Validator, or only Core JSON Schemas?
I think there is some confusion here.
Hyper schema is a way of defining links in your schema, so that given a json text, you can find other related json texts. But what you're describing is json reference (ie. $ref
properties).
The way that json references work is that the uri is substituted for the json text at that uri.
http://some-server.com/my-schema
or http://some-server.com/my-schema.json
) then the uri is loaded and substituted in. If the server returns a json text when you do not include the .json
then that's fine, it's up to them.my-schema.json
if the path you ask for is my-schema
.I'm not sure which of these scenarios is the one you are seeing. Does that help explain why your example does not work?
I've also run into this problem where an error is returned as "No such file or document". The real error (which could be a syntax error in the json schema) is being suppressed by the "No such file or document" error. I did some debugging and I found out it's the addressable gem that is causing the problem. The addressable gem has been updated to 2.4. In your previous version 2.5.0 you have set the gemspec for addressable as ~> 2.3 but in the current version 2.6.0 the gemspec says ~> 2.3.8 which will not update addressable to the latest version 2.4.
The problem is Addressable::URI.parse returns 2 different things depending on the version. Version 2.4 returns a formatting error (which I believe is the real error) and version 2.3.8 returns an Addressable object which then gets through to this method in the initialize_schema method.
schema = @options[:schema_reader].read(schema_ui)
This returns the "No such file or document" error. I believe this is the problem, but you can check me on that.
Can i avoid loading json pointers as a file with non-relative paths?
I have my JSON schema file. Where i use $ref option
that is part of my object schema;
this schema is autogenerated with PRMD gem, just filled some details. It works , prmd gem verify it as a proper .
But if I try to use
(that just load json, select this part of it that i need and pass it to validate), it fails on $ref with:
I am not sure why it even try to load /schemata/resource_name file since he get json with that data inside anyway..
Am I doing something wrong or it is like TODO? Or maybe it is because i pass data instead of path for #validate method ?