jayschema
jayschema copied to clipboard
TypeError: Cannot convert undefined or null to object
~/code/java/raml-test >jayschema json/request_address_correction.json schema/request_address_correction.schema.json
/usr/local/lib/node_modules/jayschema/lib/schemaRegistry.js:59
if (!Object.prototype.hasOwnProperty.call(currentSchema, element)) {
^
TypeError: Cannot convert undefined or null to object
at hasOwnProperty (native)
at Function.SchemaRegistry._resolveJsonPointer (/usr/local/lib/node_modules/jayschema/lib/schemaRegistry.js:59:42)
at SchemaRegistry.get (/usr/local/lib/node_modules/jayschema/lib/schemaRegistry.js:257:29)
at run (/usr/local/lib/node_modules/jayschema/lib/suites/draft-04/index.js:93:43)
at module.exports (/usr/local/lib/node_modules/jayschema/lib/suites/draft-04/keywords/_propertiesImpl.js:44:30)
at run (/usr/local/lib/node_modules/jayschema/lib/suites/draft-04/index.js:126:28)
at JaySchema._validateImpl (/usr/local/lib/node_modules/jayschema/lib/jayschema.js:227:10)
at JaySchema.validate (/usr/local/lib/node_modules/jayschema/lib/jayschema.js:294:29)
at Object.<anonymous> (/usr/local/lib/node_modules/jayschema/bin/validate.js:66:17)
at Module._compile (module.js:460:26)
Looks like it's caused by a $ref
with a filename. Here's the schema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "foo",
"type": "object",
"properties": {
"order_id": { "type": "integer" },
"shipping_address": { "$ref": "definitions.json#/address" }
},
"additionalProperties": false
}
When "definitions.json"
is removed the error is gone, but the $ref
cannot be found.
Same problem here. Has there been a work around in the time since this post?