Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 9 additions & 57 deletions .github/workflows/validate-schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ on:
paths:
- 'schemas/**'
- 'examples/**'
- 'scripts/**'
- 'package.json'
- '.github/workflows/validate-schemas.yml'
pull_request:
paths:
- 'schemas/**'
- 'examples/**'
- 'scripts/**'
- 'package.json'
- '.github/workflows/validate-schemas.yml'

jobs:
Expand All @@ -21,62 +25,10 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install ajv-cli
run: npm install -g ajv-cli ajv-formats
- name: Install dependencies
run: npm ci

- name: Validate schemas compile
run: |
# Compile standalone schemas
for f in schemas/anchor.schema.json schemas/asset-index.schema.json \
schemas/content.schema.json schemas/dublin-core.schema.json \
schemas/manifest.schema.json schemas/precise-layout.schema.json \
schemas/presentation.schema.json schemas/provenance.schema.json; do
echo "Compiling $f..."
ajv compile -s "$f" --spec=draft2020 --strict=false
done

# Compile schemas with cross-references (need -r for referenced schemas)
echo "Compiling schemas/annotations.schema.json..."
ajv compile -s schemas/annotations.schema.json \
-r schemas/anchor.schema.json --spec=draft2020 --strict=false
echo "Compiling schemas/phantoms.schema.json..."
ajv compile -s schemas/phantoms.schema.json \
-r schemas/anchor.schema.json --spec=draft2020 --strict=false

- name: Validate example documents
run: |
# Validate simple-document
ajv validate -s schemas/manifest.schema.json \
-d examples/simple-document/manifest.json \
--spec=draft2020 --strict=false
ajv validate -s schemas/content.schema.json \
-d examples/simple-document/content/document.json \
--spec=draft2020 --strict=false
ajv validate -s schemas/dublin-core.schema.json \
-d examples/simple-document/metadata/dublin-core.json \
--spec=draft2020 --strict=false

# Validate signed-document
ajv validate -s schemas/manifest.schema.json \
-d examples/signed-document/manifest.json \
--spec=draft2020 --strict=false
ajv validate -s schemas/content.schema.json \
-d examples/signed-document/content/document.json \
--spec=draft2020 --strict=false
ajv validate -s schemas/dublin-core.schema.json \
-d examples/signed-document/metadata/dublin-core.json \
--spec=draft2020 --strict=false

# Validate comprehensive-document (if exists)
if [ -d examples/comprehensive-document ]; then
ajv validate -s schemas/manifest.schema.json \
-d examples/comprehensive-document/manifest.json \
--spec=draft2020 --strict=false
ajv validate -s schemas/content.schema.json \
-d examples/comprehensive-document/content/document.json \
--spec=draft2020 --strict=false
ajv validate -s schemas/dublin-core.schema.json \
-d examples/comprehensive-document/metadata/dublin-core.json \
--spec=draft2020 --strict=false
fi
- name: Validate schemas and examples
run: npm test
Loading