You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and then replacing the above $ref with the following:
"$ref": "http://rubbish.com/user/schemaB.json#"
However this approach is problematic for the following reasons:
instead of the $ref relationship being self defining in its own right within the schema, I have to set up an external "meaningless" domain relationship just to access a relative schema on the local server.
I have no need to access schemas via web domains so http is meaningless for my use case.
The external resolver() mapping requirement means the schema is not self defining and so external applications such as XMLspy cannot use or validate the schema as http://rubbish.com/user/schemaB.json is only meaningful to opis.
Am I doing something wrong? ie. is there a way to make schema A reference local schema B via "$ref": "file:///......" without any requirement for an external mapping or is this a very very welcome piece of functionality that could be added?
(and even better would be the ability to use a "relative inter-schema $ref" eg file://./some/dir/schemaB.json rather than absolute - not sure if this is possible?)
Thanks so much!
The text was updated successfully, but these errors were encountered:
@ricky-rockstar the JSON Schema specification recommends against automatically retrieving references by default. Implementations that do offer automatic retrieval (whether by default or otherwise) are not required to automatically support any particular set of URI schemes/protocols.
I'm not familiar enough with how Opis is implemented to offer advice on how it works now, but I'd expect that you'd need to set up a resolver for file:// URIs that would do the necessary filesystem I/O. In my experience, you rarely actually want to use file:// in $id or $ref. It's much more common to use https:// (or even urn: or tag: if you don't want to imply network access) in $id or $ref and then configure a resolver that loads those schemas from the filesystem.
$id is intended to be an identifier, not a locator- so having an https:// or urn: identifier regardless of how the schema is located (in your case, from the filesystem) is pretty common.
XMLspy successfully validates JSON schema A containing the following valid file URI reference to schema B on the local C drive :
"$ref": "file:///C:/Git/Test/schemaValidate/user/schemaB.json#"
ie. as long as schemaB.json exists at the local location and is a valid json schema, schema A validates successfully.
In opis schema A does not validate.
I can set up an external opis workaround by using:
$validator->resolver()->registerPrefix("http://rubbish.com/","C:\\Git\\Test\\schemaValidate");
and then replacing the above $ref with the following:
"$ref": "http://rubbish.com/user/schemaB.json#"
However this approach is problematic for the following reasons:
Am I doing something wrong? ie. is there a way to make schema A reference local schema B via "$ref": "file:///......" without any requirement for an external mapping or is this a very very welcome piece of functionality that could be added?
(and even better would be the ability to use a "relative inter-schema $ref" eg file://./some/dir/schemaB.json rather than absolute - not sure if this is possible?)
Thanks so much!
The text was updated successfully, but these errors were encountered: