metadata: run json schema validation for actuators + parameter metadata

This commit is contained in:
Beat Küng
2021-11-23 12:40:22 -05:00
committed by Daniel Agar
parent 2809dd8944
commit 312d84ca23
3 changed files with 16 additions and 0 deletions
+6
View File
@@ -5,6 +5,7 @@ https://json-schema.org/"""
import argparse
import sys
import json
import os
try:
from jsonschema import validate
@@ -21,6 +22,8 @@ parser = argparse.ArgumentParser(description='Validate JSON file(s) against a sc
parser.add_argument('json_file', nargs='+', help='JSON config file(s)')
parser.add_argument('--schema-file', type=str, action='store',
help='JSON schema file', required=True)
parser.add_argument('--skip-if-no-schema', dest='skip_if_no_schema', action='store_true',
help='Skip test if schema file does not exist')
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
help='Verbose Output')
@@ -29,6 +32,9 @@ schema_file = args.schema_file
json_files = args.json_file
verbose = args.verbose
if args.skip_if_no_schema and not os.path.isfile(schema_file):
sys.exit(0)
# load the schema
with open(schema_file, 'r') as stream:
schema = json.load(stream)