#!/bin/bash
# validate-all.sh - Validate all JSON files against schema

SCHEMA="vendor/rpi-imager/doc/json-schema/os-list-schema.json"

for json_file in *.json; do
    echo -n "Validating $json_file... "
    if python3 -c "
import json, jsonschema, sys
try:
    schema = json.load(open('$SCHEMA'))
    print(schema)
    data = json.load(open('$json_file'))
    jsonschema.validate(data, schema)
    print('✓')
except Exception as e:
    print(f'✗ {e}')
    sys.exit(1)
    "; then
        continue
    else
        echo "Validation failed for $json_file"
        exit 1
    fi
done

echo "All files validated successfully!"
