https://github.com/willfarrell/ajv-cmd
Transpile JSON-Schema (.json) files to JavaScript (.js or .mjs) using ajv
https://github.com/willfarrell/ajv-cmd
Last synced: 9 months ago
JSON representation
Transpile JSON-Schema (.json) files to JavaScript (.js or .mjs) using ajv
- Host: GitHub
- URL: https://github.com/willfarrell/ajv-cmd
- Owner: willfarrell
- License: mit
- Created: 2022-10-03T04:28:00.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-12T15:23:16.000Z (about 1 year ago)
- Last Synced: 2025-03-24T03:23:11.729Z (12 months ago)
- Language: JavaScript
- Size: 229 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ajv-cmd
Deref, Validate, Transpile, and Test JSON-Schema (.json) files using ajv.
### Setup
```bash
$ npm install -D ajv-cmd
$ ajv --help
```
Based off of [ajv-cli](https://ajv.js.org/packages/ajv-cli.html).
## Examples
### Pre-transpile all handler schemas
```bash
#!/usr/bin/env bash
function bundle {
ajv validate ${1} --valid \
--strict true --coerce-types array --all-errors true --use-defaults empty
ajv transpile ${1} \
--strict true --coerce-types array --all-errors true --use-defaults empty \
-o ${1%.json}.js
}
for file in handlers/*/schema.*.json; do
if [ ! -n "$(bundle $file | grep ' is valid')" ]; then
echo "$file failed"
exit 1
fi
done
```