Skip to content

ADRs: types derivation & x-gts-traits-schema & x-gts-traits changes #171

ADRs: types derivation & x-gts-traits-schema & x-gts-traits changes

ADRs: types derivation & x-gts-traits-schema & x-gts-traits changes #171

name: Validate Schemas
on:
push:
branches: [ main, examples/** ]
pull_request:
branches: [ main ]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install ajv-cli
run: npm install -g ajv-cli
- name: Validate schemas
run: |
echo "Validating all schema files..."
# Compile all schemas together so cross-references can be resolved
# The 0-prefixed reference schema loads first alphabetically
set +e
AJV_OUT="$(ajv compile -s "examples/*/types/*.schema.json" --strict=false 2>&1 | grep "^error: " || true)"
AJV_CODE=$?
set -e
if [ "$AJV_CODE" -eq 0 ]; then
echo "OK: all schemas are valid"
exit 0
fi
# If the only failures are "can't resolve reference", treat them as warnings.
# This allows schemas to be validated syntactically even when external $ref targets
# (or custom URI schemes) are intentionally not resolvable in CI.
UNRESOLVED="$(echo "$AJV_OUT" | grep -Ei "can't resolve reference|cannot resolve reference|can not resolve reference" || true)"
OTHER="$(echo "$AJV_OUT" | grep -Eiv "can't resolve reference|cannot resolve reference|can not resolve reference" || true)"
if [ -n "$OTHER" ]; then
echo "$AJV_OUT"
echo "ERROR: schema validation failed"
exit 1
fi
if [ -n "$UNRESOLVED" ]; then
echo "WARN: some $ref targets could not be resolved (allowed):"
echo "$UNRESOLVED"
exit 0
fi
echo "$AJV_OUT"
echo "ERROR: schema validation failed"
exit 1