5

Is there any way to load a json schema in AJV with URL. I was using this code to load a json schema from mockable.io.

var ajv = new Ajv({ loadSchema: loadSchema });

ajv.compileAsync("http://demo3880044.mockable.io/").then(function (validate) {
  var valid = validate(data);
});

function loadSchema(uri) {
  return request.json(uri).then(function (res) {
    if (res.statusCode >= 400)
      throw new Error('Loading error: ' + res.statusCode);
    return res.body;
  });
}

But I am receiving this error:

Error: schema should be object or boolean

Any ideas?

Thanks for your help.

James Hameson
  • 331
  • 1
  • 4
  • 10

0 Answers0