mirror of
https://github.com/GNS3/gns3-registry.git
synced 2024-12-20 21:33:09 +00:00
Use additionalProperties = False only during the validation. Fixes #538
This commit is contained in:
parent
99878a86b7
commit
ff58d86256
17
check.py
17
check.py
@ -29,6 +29,18 @@ SCHEMA_VERSIONS = [3, 4, 5, 6]
|
|||||||
|
|
||||||
warnings = 0
|
warnings = 0
|
||||||
|
|
||||||
|
|
||||||
|
def no_additional_properties(schema):
|
||||||
|
if 'items' in schema:
|
||||||
|
schema = schema['items']
|
||||||
|
if 'properties' in schema:
|
||||||
|
if 'additionalProperties' not in schema:
|
||||||
|
schema['additionalProperties'] = False
|
||||||
|
for key in schema['properties']:
|
||||||
|
if isinstance(schema['properties'][key], dict):
|
||||||
|
no_additional_properties(schema['properties'][key])
|
||||||
|
|
||||||
|
|
||||||
def validate_schema(appliance_json, name, schemas):
|
def validate_schema(appliance_json, name, schemas):
|
||||||
global warnings
|
global warnings
|
||||||
|
|
||||||
@ -51,13 +63,11 @@ def validate_schema(appliance_json, name, schemas):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def signal_abort(sig, frame):
|
def signal_abort(sig, frame):
|
||||||
print('\n\n=> Check aborted\n')
|
print('\n\n=> Check aborted\n')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def check_appliance(appliance):
|
def check_appliance(appliance):
|
||||||
global warnings
|
global warnings
|
||||||
images = {}
|
images = {}
|
||||||
@ -68,6 +78,7 @@ def check_appliance(appliance):
|
|||||||
schema_filename = "schemas/appliance_v{}.json".format(version)
|
schema_filename = "schemas/appliance_v{}.json".format(version)
|
||||||
with open(schema_filename) as f:
|
with open(schema_filename) as f:
|
||||||
schemas[version] = json.load(f)
|
schemas[version] = json.load(f)
|
||||||
|
no_additional_properties(schemas[version])
|
||||||
|
|
||||||
with open(os.path.join('appliances', appliance)) as f:
|
with open(os.path.join('appliances', appliance)) as f:
|
||||||
appliance_json = json.load(f)
|
appliance_json = json.load(f)
|
||||||
@ -124,6 +135,7 @@ def image_get_height(filename):
|
|||||||
|
|
||||||
use_imagemagick = shutil.which("identify")
|
use_imagemagick = shutil.which("identify")
|
||||||
|
|
||||||
|
|
||||||
def check_symbol(symbol):
|
def check_symbol(symbol):
|
||||||
licence_file = os.path.join('symbols', symbol.replace('.svg', '.txt'))
|
licence_file = os.path.join('symbols', symbol.replace('.svg', '.txt'))
|
||||||
if not os.path.exists(licence_file):
|
if not os.path.exists(licence_file):
|
||||||
@ -159,5 +171,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
print("Everything is ok!")
|
print("Everything is ok!")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user