relax JSON schema validation (#9332)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
geoffdowns
2025-09-24 09:55:32 -07:00
committed by GitHub
parent d8b895a2f1
commit 4f49341ce9
2 changed files with 137 additions and 1 deletions
+12 -1
View File
@@ -9,7 +9,18 @@ import * as addFormats from 'ajv-formats';
// Ajv's ESM/CJS interop: use 'any' for compatibility as recommended by Ajv docs
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const AjvClass = (AjvPkg as any).default || AjvPkg;
const ajValidator = new AjvClass();
const ajValidator = new AjvClass(
// See: https://ajv.js.org/options.html#strict-mode-options
{
// strictSchema defaults to true and prevents use of JSON schemas that
// include unrecognized keywords. The JSON schema spec specifically allows
// for the use of non-standard keywords and the spec-compliant behavior
// is to ignore those keywords. Note that setting this to false also
// allows use of non-standard or custom formats (the unknown format value
// will be logged but the schema will still be considered valid).
strictSchema: false,
},
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const addFormatsFunc = (addFormats as any).default || addFormats;
addFormatsFunc(ajValidator);