ajv-validator / ajv-merge-patch

$merge and $patch keywords for Ajv JSON-Schema validator to extend schemas
https://ajv.js.org
MIT License
46 stars 17 forks source link

Update for ajv v6 #19

Closed ShaharHD closed 5 years ago

ShaharHD commented 6 years ago

Gives out an error:

error: uncaughtException: can't resolve reference http://json-schema.org/draft-06/schema#

Using the library in TypeScript v2.5

the following code produce the error:

import * as Ajv from 'ajv';
import * as AjvAsync from 'ajv-async';

import * as AjvKeywords from 'ajv-keywords';
import * as AjvMergePatch from 'ajv-merge-patch';

export const ajv = AjvAsync(new Ajv({
  coerceTypes: 'array',
  jsonPointers: true,
  allErrors: true,
  $data: true,
  removeAdditional: true,
}));

AjvMergePatch(ajv);
AjvKeywords(ajv);
epoberezkin commented 6 years ago

To work around you can just add meta-schema for draft-06. See https://github.com/epoberezkin/ajv#using-version-6