Skip to content

Commit

Permalink
Fix: validating same schema multiple times when it has $id (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
cykoder authored Oct 25, 2023
1 parent b3757fe commit d3f63d3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/schema-processor/json/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export class JsonSchemaValidator {
if (validator.formats && !Object.keys(validator.formats).length) {
addFormats(validator);
}
const validate = validator.compile(schema);
const validate =
(schema.$id ? validator.getSchema(schema.$id) : undefined) || validator.compile(schema);
const valid = validate(data);
if (!valid) {
throw new Error(validate.errors?.map((e) => e.message).join(', '));
Expand Down

0 comments on commit d3f63d3

Please sign in to comment.