#json-schema #schema-validation #schema #json #validation #command-line #command-line-tool

bin+lib scheval

A fast and smart command-line tool for JSON Schema validation, powered by the jsonschema crate

3 releases

0.1.2 Jan 3, 2025
0.1.1 Jan 2, 2025
0.1.0 Dec 23, 2024

#2207 in Command line utilities

Download history 90/week @ 2024-12-18 41/week @ 2024-12-25 295/week @ 2025-01-01

426 downloads per month

MIT license

26KB
447 lines

scheval

GitHub License GitHub Workflow Status GitHub Release GitHub Downloads (all assets, all releases) GitHub Downloads (all assets, latest release) Crates.io Version Crates.io Total Downloads

A fast and smart command-line tool for JSON Schema validation, powered by the jsonschema crate. Currently still in development.

🚀 Installation

If you have cargo-binstall, you can install this tool by running:

$ cargo binstall scheval

Otherwise, you can install it from source:

$ cargo install scheval

✨ Features

Including

  • vscode: Respect json.schemas field at .vscode/settings.json if present
  • suffix: Validate <filename>.json with <filename>.schema.json under working directory

Excluding

TBD

🚀 Quick Start

scheval can be run without any arguments. It will automatically use all available features.

$ scheval

Alternatively, you can specify a list of smart including features to use:

$ scheval --include vscode # Uses only `vscode`
$ scheval --include suffix # Uses only `suffix`
$ scheval --include vscode --include suffix # Uses both `vscode` and `suffix`
$ # Shorthands provided by `clap`
$ scheval -i vscode -i suffix
$ scheval -ivscode -isuffix

📚 Usage

$ scheval --help
A fast and *smart* command-line tool for JSON Schema validation, powered by the `jsonschema` crate.

Usage: scheval [OPTIONS]

Options:
  -i, --include <INCLUDE>
          What smart including features to use. Available: `vscode`, `suffix`. Default to all

          - `vscode`: Respect `json.schemas` field at `.vscode/settings.json` if present
          - `suffix`: Validate `<filename>.json` with `<filename>.schema.json` under working directory

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

📝 Notes

This project uses globwalk for pattern matching, which might be buggy. Notably in fileMatch field:

  • ./ is not supported (I've included a quick fix by removing the prefix, but have not considered other cases, like ././ or !./)
  • ../ is not supported (A warning will be shown, and the pattern will be ignored)

If you have a good alternative which supports VSCode's fileMatch syntax, please let me know.

Possible alternatives:

TODO

  • Implement vscode auto detection
    • Better support for fileMatch
      • Relative path
      • Absolute path (workspace)
    • Support for url
      • Local schema (path)
      • Remote schema (URL)
    • Support for schema (Inline schema)
  • Smartly exclude paths
  • Add more tests & documentation
  • Better error handling
  • Output
  • Improve performance using references
  • Possibly adding more features
  • Reduce binary size
  • Automation using GitHub Actions
    • Release (respecting cargo-binstall)
    • Publish

Dependencies

~11–20MB
~293K SLoC