rushstack
rushstack copied to clipboard
[node-core-library] Implement json-schema 'draft-07' validation
Summary
[node-core-library] Implements json-schema 'draft-07' validation in JsonFile / JsonSchema
Fixes https://github.com/microsoft/rushstack/issues/4713
Details
This PR:
- Upgrades 'ajv' from v6.x to v8.x in the rush repo
- see for more information https://ajv.js.org/v6-to-v8-migration.html
- Replaces the 'z-schema' library with 'ajv' in
@rushstack/node-core-library- This migration is required to be able to properly support json-schema draft-07 (and other future specifications), z-schema does not see very active development anymore.
- Updates the schema validator error-detail helper to error details exposed by ajv
- Since ajv uses a slightly different error message format, there are a couple of small breaking changes in downstream project that have test assertions on them.
- Use 'ajv-draft-04' to retain backwards compatibility with json-schema draft-04
- see https://ajv.js.org/guide/schema-language.html#draft-04
ajvapplies additional validation on the correctness of the schema per https://ajv.js.org/options.html#strictschema- this surfaced a small issue in the heft schema validation where 'items' keyword was incorrectly combined with the
stringtype.
- this surfaced a small issue in the heft schema validation where 'items' keyword was incorrectly combined with the
Notes:
- Schema definitions that don't have a schema defined will now default to draft-07.
- There are likely some performance gains with the migration from 'z-schema' to 'ajv' that where not quantified, more background https://ajv.js.org/guide/why-ajv.html#super-fast-secure.
How it was tested
- validated the existing unit tests and updated the new error detail snapshot
- added new unit test to specifically test draft-04, draft-07 and nested schemas
Impacted documentation
N/A