A Command-line utility that extends CLI for Ajv JSON schema validators to support GeoJSON files.
Popular CLI packages for the Ajv JSON schema validator do not support validating GeoJSON files directly if their extension is *.geojson
. The behaviour has been described in issue 152 of the canonical but unmaintained Ajv CLI package.
ajv-geojson-shim is a bash script wrapper around existing Ajv CLI packages that adds GeoJSON support by:
- Accepting all standard Ajv CLI arguments and options
- Detecting
.geojson
files in the parameters - Creating temporary
.json
copies of those files - Passing the temporary files to the underlying Ajv validator
- Cleaning up temporary files after validation
Make sure you have installed either ajv-cli or the actively maintained @jirutka/ajv-cli. You can install them as local dependency or globally using the -g
flag:
npm install -g ajv-cli # or
npm install -g @jirutka/ajv-cli
Manual Installation: Clone this repository, make the script executable:
git clone https://github.com/tomkyle/ajv-geojson-shim.git
Install to your PATH: This step is optional. It will copy the script to ~/.local/bin/
. Make sure this directory is in your $PATH variable.
make install
ajv-geojson-shim validate -s schema.json -d data.geojson
The script supports all commands and options of the underlying Ajv CLI package. Some examples:
# Validate a GeoJSON file against a schema
ajv-geojson-shim validate -s schema.json -d data.geojson
# Validate multiple files, including both JSON and GeoJSON
ajv-geojson-shim validate -s schema.json -d data1.json data2.geojson
# Test a schema with a GeoJSON file
ajv-geojson-shim test -s schema.json -d data.geojson
ajv-geojson-shim/
├── bin/
│ └── ajv-geojson-shim # Main script
├── test/
│ ├── test-unit.sh # Unit tests
│ ├── test-integration.sh # Integration tests
│ ├── test-helpers.sh # Test helpers
│ └── fixtures/ # Fixture files
│ ├── *.json # Example JSON and schema
│ └── *.geoson # Example GeoJSON
├── Makefile # Build and test automation
└── README.md # Documentation
The project includes both unit tests and integration tests:
# Run all tests
make test
# Run only unit/integration tests
make unit-test
make integration-test
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Run tests to ensure they pass:
make test
- Commit your changes:
git commit -m 'Add some amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
MIT License - Copyright (c) 2025 Carsten Witt