Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sourcemeta/jsonschema
The CLI for working with JSON Schema. Covers formatting, linting, testing, bundling, and more for both local development and CI/CD pipelines
https://github.com/sourcemeta/jsonschema
asyncapi cpp json json-schema json-schemas jsonschema openapi schema schemas schemastore tooling tools
Last synced: 6 days ago
JSON representation
The CLI for working with JSON Schema. Covers formatting, linting, testing, bundling, and more for both local development and CI/CD pipelines
- Host: GitHub
- URL: https://github.com/sourcemeta/jsonschema
- Owner: sourcemeta
- License: agpl-3.0
- Created: 2024-05-18T18:43:27.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-10-28T21:42:31.000Z (8 days ago)
- Last Synced: 2024-10-28T22:29:11.486Z (8 days ago)
- Topics: asyncapi, cpp, json, json-schema, json-schemas, jsonschema, openapi, schema, schemas, schemastore, tooling, tools
- Language: Shell
- Homepage: https://jsonschema.intelligence.ai
- Size: 3.8 MB
- Stars: 58
- Watchers: 2
- Forks: 5
- Open Issues: 12
-
Metadata Files:
- Readme: README.markdown
- Contributing: CONTRIBUTING.markdown
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - sourcemeta/jsonschema - The CLI for working with JSON Schema. Covers formatting, linting, testing, bundling, and more for both local development and CI/CD pipelines (Shell)
README
![JSON Schema](./assets/banner.png)
The command-line tool for working with [JSON Schema](https://json-schema.org),
the world most popular schema language. It is a comprehensive solution for
maintaining **repositories of schemas** and ensuring their quality, both during
local development and when running on CI/CD pipelines. For example:- Ensure your schemas are valid
- Unit test your schemas against valid and invalid instances
- Enforce consistent indentation and keyword ordering in your schema files
- Detect and fix common JSON Schema anti-patterns
- Inline external references for conveniently distributing your schemas[**Check out the documentation to learn more**](#usage)
***
> [!TIP]
> Do you want to level up your JSON Schema skills? Check out
> [learnjsonschema.com](https://www.learnjsonschema.com), our growing JSON
> Schema documentation website, and our O'Reilly book [Unifying Business, Data,
> and Code: Designing Data Products with JSON
> Schema](https://www.oreilly.com/library/view/unifying-business-data/9781098144999/).Version support
---------------We aim to fully support _every_ version of JSON Schema and combinations between them.
| Dialect | Support |
|---------------------|------------------------------------------------------------------|
| JSON Schema 2020-12 | **Full** |
| JSON Schema 2019-09 | **Full** |
| JSON Schema Draft 7 | **Full** |
| JSON Schema Draft 6 | **Full** |
| JSON Schema Draft 4 | **Full** |
| JSON Schema Draft 3 | Partial (except `validate`, `test`, `metaschema`, and `compile`) |
| JSON Schema Draft 2 | Partial (except `validate`, `test`, `metaschema`, and `compile`) |
| JSON Schema Draft 1 | Partial (except `validate`, `test`, `metaschema`, and `compile`) |
| JSON Schema Draft 0 | Partial (except `validate`, `test`, `metaschema`, and `compile`) |What our users are saying
-------------------------> Amazing product. Very useful for formatting and bundling my schemas, plus it
> surfaced various referencing issues. 10 out of 10![@alombarte](https://github.com/alombarte), co-founder of the
[KrakenD](https://www.krakend.io) API Gateway.Usage
-----The functionality provided by the JSON Schema CLI is divided into commands. The
following pages describe each command in detail. Additionally, running the JSON
Schema CLI without passing a command will print convenient reference
documentation:- [`jsonschema validate`](./docs/validate.markdown)
- [`jsonschema metaschema`](./docs/metaschema.markdown) (ensure a schema is valid)
- [`jsonschema test`](./docs/test.markdown) (write unit tests for your schemas)
- [`jsonschema fmt`](./docs/format.markdown)
- [`jsonschema lint`](./docs/lint.markdown)
- [`jsonschema bundle`](./docs/bundle.markdown) (for inlining remote references in a schema)
- [`jsonschema frame`](./docs/frame.markdown) (for debugging references)
- [`jsonschema compile`](./docs/compile.markdown) (for internal debugging)
- [`jsonschema identify`](./docs/identify.markdown)
- [`jsonschema canonicalize`](./docs/canonicalize.markdown) (for static analysis)
- [`jsonschema encode`](./docs/encode.markdown) (for binary compression)
- [`jsonschema decode`](./docs/decode.markdown)Installation
------------The JSON Schema CLI is written using C++ and [CMake](https://cmake.org/), and
supports macOS, Windows, and GNU/Linux. Under the hood, it relies on the
powerful [JSON Toolkit](https://github.com/sourcemeta/jsontoolkit) library.### From Homebrew
```sh
brew install sourcemeta/apps/jsonschema
```### From GitHub Actions
```yaml
- uses: sourcemeta/[email protected]
```Where `X.Y.Z` is replaced with the desired version. For example:
```yaml
- uses: sourcemeta/[email protected]
# Then use as usual
- run: jsonschema fmt path/to/schemas --check
```### From NPM
```sh
npm install --global @sourcemeta/jsonschema
```### From GitHub Releases
We publish precompiled binaries for every supported platform to [GitHub
Releases](https://github.com/sourcemeta/jsonschema/releases), including a
[continuous](https://github.com/sourcemeta/jsonschema/releases/tag/continuous)
that is updated on every commit from the main branch.For convenience, we also provide a POSIX shell script capable of installing the
latest pre-built binaries, which you can run as follows:```sh
/bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/sourcemeta/jsonschema/main/install -H "Cache-Control: no-cache, no-store, must-revalidate")"
```### From Dockerfile
You can compile the JSON Schema CLI inside a container and run it with Docker
as follows:```sh
docker build -t jsonschema .
```Then, you run the JSON Schema CLI by mounting the desired directory as
`/workspace` as follows:```sh
docker run --interactive --volume "$PWD:/workspace" jsonschema lint --verbose myschema.json# You can optionally add this to your .alias (or similar) file:
# alias jsonschema="docker run --interactive --volume \"$PWD:/workspace\" jsonschema"
```> [!WARNING]
> Make sure to NOT allocate a pseudo-TTY when running the CLI through Docker
> (i.e. the `--tty`/`-t` option) as it might result in line ending
> incompatibilities between the container and host, which will affect
> formatting. Plus a TTY is not required for running a tool like the JSON
> Schema CLI.### Building from source
```sh
git clone https://github.com/sourcemeta/jsonschema
cd jsonschema
cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=Release
cmake --build ./build --config Release --parallel 4
cmake --install ./build --prefix \
--config Release --verbose --component sourcemeta_jsonschema
```Where `` can be any destination prefix of your choosing, such as `/opt`
or `/usr/local`.Coming Soon
-----------This project is under heavy development, and we have a lot of cool things in
the oven. In the mean-time, star the project to show your support!| Feature | Description | Status |
|-----------------------|------------------------------------------------------------------------------------|-------------|
| Debugging | Validate a JSON instance against a JSON Schema step by step, like LLDB and GDB | Not started |
| Upgrading/Downgrading | Convert a JSON Schema into a later or older dialect | Not started |License
-------This project is governed by the [AGPL-3.0](./LICENSE) copyleft license.