Skip to content

Commit

Permalink
Make retrieving meta-schemas more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
jdesrosiers committed Aug 2, 2024
1 parent cd62e74 commit edbd7e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ subscribe("validate.metaValidate", async (_message, schema) => {

// Compile
if (!(schema.document.dialectId in metaValidators)) {
const metaSchema = await getSchema(schema.document.dialectId);
const metaSchema = await getSchema(schema.document.dialectId, schema);
const compiledSchema = await compile(metaSchema);
metaValidators[schema.document.dialectId] = interpret(compiledSchema);
}
Expand Down
6 changes: 4 additions & 2 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ const schemaRegistry = {};
export const getSchema = async (uri, browser = undefined) => {
if (!browser) {
browser = { _cache: {} };
}

for (const uri in schemaRegistry) {
for (const uri in schemaRegistry) {
if (!(uri in browser._cache)) {
browser._cache[uri] = schemaRegistry[uri];
}
}

const schema = await browserGet(uri, browser);
const schema = await browserGet(uri, { ...browser });
if (typeof schema.document.dialectId !== "string") {
throw Error(`The document at ${schema.document.baseUri} is not a schema.`);
}
Expand Down

0 comments on commit edbd7e8

Please sign in to comment.