forked from M-Labs/artiq
jsondesc: Disallow unknown properties
This helps to catch typos made in drafting core device schemata. For instance, previously typo'ing `"edge_counter": true` as `"edge_counters": true` would lead to it silently being ignored. This required switching to a (meta-)schema version more recent by one release, as unevaluatedProperties is not supported in draft-7 yet.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$id": "https://m-labs.hk/kasli_generic.schema.json",
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
||||
"title": "Kasli variant description",
|
||||
|
||||
"type": "object",
|
||||
@@ -166,6 +166,7 @@
|
||||
}
|
||||
},
|
||||
"required": ["type"],
|
||||
"unevaluatedProperties": false,
|
||||
"allOf": [{
|
||||
"title": "DIO",
|
||||
"if": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from os import path
|
||||
import json
|
||||
from jsonschema import Draft7Validator, validators
|
||||
from jsonschema import Draft201909Validator, validators
|
||||
|
||||
def extend_with_default(validator_class):
|
||||
validate_properties = validator_class.VALIDATORS["properties"]
|
||||
@@ -23,7 +23,7 @@ schema_path = path.join(path.dirname(__file__), "coredevice_generic.schema.json"
|
||||
with open(schema_path, "r") as f:
|
||||
schema = json.load(f)
|
||||
|
||||
validator = extend_with_default(Draft7Validator)(schema)
|
||||
validator = extend_with_default(Draft201909Validator)(schema)
|
||||
|
||||
def load(description_path):
|
||||
with open(description_path, "r") as f:
|
||||
|
||||
Reference in New Issue
Block a user