Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[node-core-library] Implement json-schema 'draft-07' validation #4714

Conversation

bartvandenende-wm
Copy link
Contributor

@bartvandenende-wm bartvandenende-wm commented May 15, 2024

Summary

[node-core-library] Implements json-schema 'draft-07' validation in JsonFile / JsonSchema

Fixes #4713

Details

This PR:

  • Upgrades 'ajv' from v6.x to v8.x in the rush repo
  • 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
    • ajv applies 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 string type.

Notes:

How it was tested

  1. validated the existing unit tests and updated the new error detail snapshot
  2. added new unit test to specifically test draft-04, draft-07 and nested schemas

Impacted documentation

N/A

@bartvandenende-wm bartvandenende-wm changed the title [node-core-library] Implements json-schema 'draft-07' validation in JsonFile / JsonSchema [node-core-library] Implement json-schema 'draft-07' validation May 15, 2024
Copy link
Member

@iclanton iclanton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall.

I'm going to disable automatic publishing for now. If we're going to do a major bump of node-core-library, there are some other changes we should make at the same time.

@iclanton iclanton enabled auto-merge May 21, 2024 02:46
auto-merge was automatically disabled May 21, 2024 03:33

Head branch was pushed to by a user without write access

@iclanton iclanton enabled auto-merge May 21, 2024 03:35
@iclanton iclanton merged commit 8321356 into microsoft:main May 21, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

[node-core-library] Add support json-schema 'draft-07' validation in JsonFile / JsonSchema
2 participants