The schema command lints JSON Schema documents directly. It does not require an OpenAPI document.

vacuum schema product.schema.json

The default ruleset is json-schema-recommended.

Lint a schema

Use vacuum schema for a single file.

vacuum schema product.schema.json -d

Use schema lint if you prefer the explicit subcommand. It does the same thing.

vacuum schema lint product.schema.json

Lint a folder

Folder inputs recursively include .json, .yaml and .yml files.

vacuum schema ./schemas

Use --include and --exclude to control folder discovery.

vacuum schema ./schemas --include "**/*.schema" --exclude "**/*.test.schema"

Quote include globs so your shell does not expand them into separate file arguments.

Lint from stdin

Use --stdin or -i to read one schema from stdin.

cat product.schema.json | vacuum schema --stdin

Bundle before linting

Some exploded JSON Schema packs need to be bundled before linting. Use --bundle to bundle a single root schema in memory, then lint the bundled document.

vacuum schema product.schema.json --bundle

--bundle is explicit. It only works with one schema file or one stdin input.

Bundle a schema

Use vacuum schema bundle to write a bundled JSON Schema document.

vacuum schema bundle product.schema.json bundled.schema.json

The bundle command rewrites ordinary external $ref values into root $defs.

{
  "properties": {
    "gift": {
      "$ref": "_defs/GiftBag.schema.json"
    }
  }
}

becomes a root $defs lookup.

{
  "properties": {
    "gift": {
      "$ref": "#/$defs/GiftBag"
    }
  },
  "$defs": {
    "GiftBag": {}
  }
}

If a bundled external schema contains a local $defs pointer such as #/$defs/Hat, vacuum will look for a sibling Hat.schema.json file, move it into the root $defs, and preserve the lookup as #/$defs/Hat.

Bundle to stdout

Use --stdout or -o to write the bundled schema to stdout.

vacuum schema bundle product.schema.json --stdout

This is useful when piping into another tool.

vacuum schema bundle product.schema.json --stdout | vacuum schema --stdin

If stdin input contains relative external refs, provide --base so vacuum knows where to resolve them from.

cat product.schema.json | vacuum schema bundle --stdin --stdout --base ./schemas

Output format

Bundling preserves the input format by default. Use --format json or --format yaml to override it.

vacuum schema bundle product.schema.yaml bundled.schema.json --format json

Folder bundling

schema bundle bundles one schema root at a time. Folder bundling is not supported.

Use folder linting when you want to lint many schemas, and use schema bundle when you want to produce one portable schema document from one root schema.

Available Flags

schema supports the following flags.

Short Full Input Description
-d –details bool Show full details of the schema linting report
-s –snippets bool Show code snippets where issues are found
-e –errors bool Show errors only
-x –silent bool Show nothing except the result
-q –no-style bool Disable color and style console output
-b –no-banner bool Hide the welcome / version banner
-n –fail-severity string Set the level at which an error return code is thrown
-i –stdin bool Read a JSON Schema document from stdin
-o –output string Write JSON lint output to a file
–format string Output format for lint results, text or json
–globbed-files string Use a glob pattern to lint multiple files
–include string Include glob for folder inputs
–exclude string Exclude glob for folder inputs
–bundle bool Bundle a single JSON Schema document in memory before linting
–ignore-file string Path to an ignore file
–show-rules bool Print out the rules being used
–no-clip bool Do not truncate long messages or paths

schema bundle supports the following flags.

Short Full Input Description
-i –stdin bool Read a JSON Schema document from stdin
-o –stdout bool Write bundled schema to stdout
–output string Write bundled schema to a file
–format string Output format for bundled documents, yaml or json
-d –delimiter string Delimiter used to separate clashing $defs names
-q –no-style bool Disable color and style console output
-p –base string Base path or URL for resolving relative references