42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import json
|
|
import jsonschema
|
|
|
|
# Cargar esquema y datos para dataset-definitions
|
|
with open("config/schema/dataset-definitions.schema.json", "r") as f:
|
|
schema = json.load(f)
|
|
|
|
with open("config/data/dataset_definitions.json", "r") as f:
|
|
data = json.load(f)
|
|
|
|
# Validar
|
|
try:
|
|
jsonschema.validate(data, schema)
|
|
print("✅ Dataset definitions validation successful!")
|
|
except jsonschema.ValidationError as e:
|
|
print("❌ Dataset definitions validation error:")
|
|
print(f'Property path: {".".join(str(x) for x in e.absolute_path)}')
|
|
print(f"Message: {e.message}")
|
|
print(f"Failed value: {e.instance}")
|
|
except Exception as e:
|
|
print(f"❌ Other error: {e}")
|
|
|
|
print("\n" + "=" * 50 + "\n")
|
|
|
|
# También validar PLC config
|
|
with open("config/schema/plc.schema.json", "r") as f:
|
|
plc_schema = json.load(f)
|
|
|
|
with open("config/data/plc_config.json", "r") as f:
|
|
plc_data = json.load(f)
|
|
|
|
try:
|
|
jsonschema.validate(plc_data, plc_schema)
|
|
print("✅ PLC config validation successful!")
|
|
except jsonschema.ValidationError as e:
|
|
print("❌ PLC config validation error:")
|
|
print(f'Property path: {".".join(str(x) for x in e.absolute_path)}')
|
|
print(f"Message: {e.message}")
|
|
print(f"Failed value: {e.instance}")
|
|
except Exception as e:
|
|
print(f"❌ Other error: {e}")
|