-
Notifications
You must be signed in to change notification settings - Fork 319
Use AJV to validate referenced schemas #1164
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
Conversation
Signed-off-by: Morgan Chang <[email protected]>
…idation tests Signed-off-by: Morgan Chang <[email protected]>
|
|
||
| // load JSON Schema 07 def to validate loaded schemas | ||
| // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
| const jsonSchema04 = require('ajv-draft-04/dist/refs/json-schema-draft-04.json'); |
Check failure
Code scanning / ESLint
Disallow `require` statements except in import statements Error
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
| const jsonSchema04 = require('ajv-draft-04/dist/refs/json-schema-draft-04.json'); | ||
| const jsonSchema2019 = require('ajv/dist/refs/json-schema-2019-09/schema.json'); |
Check failure
Code scanning / ESLint
Disallow `require` statements except in import statements Error
| const jsonSchema04 = require('ajv-draft-04/dist/refs/json-schema-draft-04.json'); | ||
| const jsonSchema2019 = require('ajv/dist/refs/json-schema-2019-09/schema.json'); | ||
| // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
| const jsonSchema2020 = require('ajv/dist/refs/json-schema-2020-12/schema.json'); |
Check failure
Code scanning / ESLint
Disallow `require` statements except in import statements Error
Signed-off-by: Morgan Chang <[email protected]>
| then?: JSONSchemaRef; | ||
| else?: JSONSchemaRef; | ||
|
|
||
| // schema draft 2019-09 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not strictly needed for this change, but I'm okay with adding it now, since we'll need to do it eventually.
datho7561
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks, Morgan!
What does this PR do?
Meta-validate the referenced schema of a YAML file against the correct meta-schema based on its
$schemavalue.This change support meta-validation for:
What issues does this PR fix or reference?
This PR replaces the hyperjump-based schema meta-validation approach in #1115 with AJV (we already depend on AJV in this project and AJV can validate JSON Schema drafts).
This improves schema meta-validation and is complementary to (but not a prerequisite for) the broader work tracked in #856 to support newer-draft instance validation.
Is it tested? How?
Added automated tests covering draft-specific meta-validation failures for each draft version supported.
Manually verified using the following JSON schemas (create a YAML file containing just the number
1and point it to each schema):