scheval

Crates.ioscheval
lib.rsscheval
version0.1.2
created_at2024-12-23 15:12:15.807815+00
updated_at2025-01-03 04:35:14.593932+00
descriptionA fast and *smart* command-line tool for JSON Schema validation, powered by the `jsonschema` crate.
homepage
repositoryhttps://github.com/PRO-2684/scheval
max_upload_size
id1493138
size67,402
PRO (PRO-2684)

documentation

README

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
Commit count: 46

cargo fmt