Ajv: "no schema" Error thrown

Created on 5 Jun 2017  路  7Comments  路  Source: ajv-validator/ajv

Hi,

First time user of AJV. I'm trying to use extract-text-webpack-plugin that depends on AJV. While this plugin is doing its thing during bundling my CSS output via webpack; AJV throws the error message:

Error: no schema with key or ref "http://json-schema.org/draft-04/schema#"

Can't understand what its complaint is. That URL will load a JSON file so its valid. I don't like the idea that my deployment is now dependent on an external URL! Is there a way to turn off what ever its doing at this point; or use a local schema?

thanks
Jab

PS
The full error stack is:

 [exec]     if (!v) throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
 [exec]             ^
 [exec]
 [exec] Error: no schema with key or ref "http://json-schema.org/draft-04/schema#"
 [exec]     at Ajv.validate (<my home directory>/node_modules/ajv/lib/ajv.js:94:19)
 [exec]     at Ajv.validateSchema (<my home directory>/node_modules/ajv/lib/ajv.js:178:22)
 [exec]     at Ajv._addSchema (<my home directory>/node_modules/ajv/lib/ajv.js:310:10)
 [exec]     at Ajv.validate (<my home directory>/node_modules/ajv/lib/ajv.js:96:26)
 [exec]     at validate (<my home directory>/node_modules/extract-text-webpack-plugin/schema/validator.js:8:20)
 [exec]     at Function.ExtractTextPlugin.extract (<my home directory>/node_modules/extract-text-webpack-plugin/index.js:204:3)
 [exec]     at Object.<anonymous> (<my build directory>/webpack-helper.k4LeH754/webpack.config.js:40:33)
 [exec]     at Module._compile (module.js:570:32)
 [exec]     at Object.Module._extensions..js (module.js:579:10)
 [exec]     at Module.load (module.js:487:32)
duplicate

Most helpful comment

I think the referenced instructions don't work for 6.x. With the same code and 5.5.2 I can successfully add a meta schema, with 6.x - I get a no schema with key or ref.
@epoberezkin

edit: oops, didn't notice the var ajv = new Ajv({schemaId: 'id'}); on top of the README.

All 7 comments

see #472

hi it's my first time using json schema and i get this issue
Uncaught Error: no schema with key or ref "http://json-schema.org/draft-04/schema#"
at Ajv.validate (ajv.js:95)
at Ajv.validateSchema (ajv.js:183)
at Ajv._addSchema (ajv.js:317)
at Ajv.validate (ajv.js:97)
at validateFormData (validate.js:196)
at Form.validate (Form.js:166)
at Form.js:87
at Form._this.onSubmit (Form.js:103)
at HTMLUnknownElement.boundFunc (ReactErrorUtils.js:63)
at Object.ReactErrorUtils.invokeGuardedCallback (ReactErrorUtils.js:69)

Same. I'm trying to figure this out.

Be careful that the version of ajv you're using, matches the schema json file you use. That will also trigger this error.

I think the referenced instructions don't work for 6.x. With the same code and 5.5.2 I can successfully add a meta schema, with 6.x - I get a no schema with key or ref.
@epoberezkin

edit: oops, didn't notice the var ajv = new Ajv({schemaId: 'id'}); on top of the README.

@jorotenev Difficult to say what's the problem without the example, but it all works. You should add all meta-schemas to the instance that are used in your schemas in "$schema" keyword. By default in v6 only draft-07 meta-schema is added, in v5 - only draft-06.

EDIT: So, if you use draft-06 schema in v5 it will just work, in v6 you either have to update $schema to be draft-07 (it's backward compatible, so it's ok), or add draft-06 meta-schema.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sundriver picture sundriver  路  3Comments

radio-miskovice picture radio-miskovice  路  6Comments

vankop picture vankop  路  4Comments

mhelvens picture mhelvens  路  5Comments

gpietro picture gpietro  路  4Comments