How can i properly load big amount of refs properly

Im loading big jsonschema from hrjson
and this will not load properly the base of href is always changing and i get strange results.

The only way i see to register in an array per file name and use resolver to load it but thats really really odd imo.

[original thread by FBurner]

Hi @fburner, I’m not sure whether the $refs in the provided schema are actually valid syntax, as they seem to be defined relatively to their file location, eg. (…/…/x/y/z.json) which I don’t think is a supported concept. Please correct me if I’m wrong :wink:

However I think you still should be able to resolve all of them within JSON Forms by:

  • Adding them to AJV, e.g. ajv.addSchema(zObject, ‘x/y/z.json’);

  • Adding them to the ref resolver options, e.g.

const myResolver = {
 order: 1,
 canRead: file => file.url.indexOf('x/y/z.json') !== -1,
 read: file => JSON.stringify(zObject)

and doing that for each involved schema.