- Introduction
- Overview
- Recommended Extensions
- Schema Authoring
- Schema Validation
- About
catalog.json - Compatible Language Servers and Tools
- Troubleshooting
- How-to
- How to add a JSON Schema that's hosted in this repository
- How to add a JSON Schema that's self-hosted/remote/external
- How to edit an existing JSON Schema
- How to add a JSON Schema with multiple versions
- How to move a JSON Schema from SchemaStore to somewhere that's self-hosted
- How to add a
$refto a JSON Schema that's hosted in this repository - How to add a
$refto a JSON Schema that's self-hosted - How to validate a JSON Schema
- How to check test coverage for a JSON Schema
- How to ignore validation errors in a JSON Schema
- How to name schemas that are subschemas (
partial-)
- Older Links
Welcome! Thank you for contributing to SchemaStore!
There are various ways you can contribute:
- Add a new JSON Schema
- Local schema
- Remote schema
- Enhance existing JSON schemas:
- Fix typos
- Fix bugs
- Improve constraints
- Add positive/negative tests
- Refactor to pass under strict mode
Most people want to add a new schema. For steps on how to do this, read the How to add a JSON Schema that's hosted in this repository section below. Find instructions for other tasks under the How To section.
If you want to contribute, but not sure what needs fixing, see the help wanted and good first issue labels on GitHub.
Schema files are located in src/schemas/json. Each schema file has a corresponding entry in the Schema Catalog. Each catalog entry has a fileMatch field. IDEs and language servers use this field to know which files the schema should be used for (in autocompletion).
Some schema files have associated positive and negative tests, located at src/test and src/negative_test, respectively. These tests may be in JSON, YAML, or TOML format.
Multiple libraries are used for validation to increase the compatibility and correctness of schemas. All schemas must correctly validate against their positive and negative tests using Ajv. Other JSON Schema libraries can be optionally used. And, the schemas themselves can be linted using "Ajv strict mode" and other libraries. More details under Schema Validation.
We highly recommend installing the following extensions for your IDE:
- EditorConfig to automatically configure editor settings
- Prettier to automatically configure file formatting
If you are modifying cli.js, we also recommend:
- ESLint to automatically show JavaScript issues
- TypeScript language server (Bundled with VSCode)
The goal of JSON Schemas in this repository is to correctly validate schemas that are used by the actual tools. That means, if a property is undocumented or deprecated, it should still be included in the schema.
- We recommend using the
draft-07JSON schema version. Later versions of JSON Schema are not yet recommended for use in SchemaStore until IDE and language support improves for those versions.
❌ Don't forget add test files.
- Consider using documentation URLs in
"description"to improve UX. Most schemas use the format<description>\n<url>. For example:"Whether to ignore a theme configuration for the current site\nhttps://jekyllrb.com/docs/configuration/options/#global-configuration" - When writing
description, avoid phrases like "there are three possibilities" and "valid values are" in favor of adding the constraints to the schema directly. - If you choose to use
title, we recommend formatting it so that object values look like types in programming languages. This includes:- Omitting leading articles and trailing punctuation
- Beginning it with a lowercase letter
- Using nouns instead of sentences
Sometimes, constraints do more harm than good. For example, cron strings validation regexes. In general, do not add a constraint if:
- false positives are likely (due to their complexity or abundance of implementations)
- its error message is too confusing or not helpful
So, we recommend avoiding regex patterns for:
- cron regexes
- string-embedded DSLs
- SSH URLs, HTTPS URLs, and other complex URIs
Be wary when adding exhaustive support to enum-type fields (without a "type": "string" fallback). Keep in mind:
- New enum values that are supported by a new tool version (and not yet added to SchemaStore) should not error
- The schema may be extended by a tool that you have no knowledge of
Do not blindly add "additionalProperties": false. Keep in mind that:
- New properties that are supported by a new tool version (and not yet added to SchemaStore) should not error
- The schema may be extended by a tool that you have no knowledge of
It is recognized that stricter checking may be desired, as in the case of checking for typos. In that case, check to see if your validator has an option for stronger checks. For example, Tombi enables a strict mode by default.
The use of undocumented features in schemas is permitted and encouraged. However they must be labeled as such.
It is preferred to add UNDOCUMENTED. to the beginning of description.
{
"type": "object",
"properties": {
"experimental_useBranchPrediction": {
"type": "string",
"description": "UNDOCUMENTED. Enables branch prediction in the build."
}
}
}However, that is not always possible or correct. Alternatively, use $comment:
{
"type": "object",
"tsBuildInfoFile": {
"$comment": "The value of 'null' is UNDOCUMENTED.",
"description": "Specify the folder for .tsbuildinfo incremental compilation files.",
"default": ".tsbuildinfo",
"type": ["string", "null"]
}
}In this case, { "tsBuildInfoFile": null } is not documented. Using a string value is, however.
Software that reads a schema may deprecate and eventually remove particular properties or features.
For most schemas, we don't recommend removing properties from schemas, especially immediately after they are no longer supported. They are useful during the migration process or if users are stuck on an older version.
To note that a property or feature is deprecated, use the same strategy as described in Undocumented Features. For example:
{
"description": "DEPRECATED. Documentation of this property. Migrate to this alternative."
}Note that JSON Schema draft 2019-09 adds support for a deprecated field:
{
"description": "Documentation of this property. Migrate to this alternative.",
"deprecated": true
}While this would be the best option, most schemas in this repository are draft-07. As a result, IDEs and language servers may not use it.
Care must be taken to reduce breaking changes; some include:
1. Preserving schema names
When renaming a schema name, the old version must continue to exist. Otherwise, all references to it will break. The content of the old schema must look something like:
{
"$ref": "https://json.schemastore.org/NEWNAME.json"
}The process of renaming schemas is similar to this section.
2. Preserving schema paths
Many tools, such as validate-pyproject, accept passing in subpaths for validation like so:
validate-pyproject --tool cibuildwheel=https://json.schemastore.org/cibuildwheel.toml#/properties/tool/propertiesThis means that renames in subschema paths is a potentially a breaking change. However, it needs to be possible to refactor internal schema structures.
It is okay when refactoring the subschema to a location under $defs or definitions. Otherwise, use your best judgement. If a rename is necessary, it is recommended to keep the old path and $ref to the new location, if possible.
There are several ways to document enums. It is recommended to use this solution:
{
"oneOf": [
{ "const": "foo", "description": "Description foo" },
{ "const": "bar", "description": "Description bar" }
]
}It is also possible to use x-intellij-enum-metadata:
{
"enum": ["foo", "bar"],
"x-intellij-enum-metadata": {
"foo": {
"description": "Description foo"
},
"bar": {
"description": "Description bar"
}
}
}Or, enumDescriptions:
{
"enum": ["foo", "bar"]
"enumDescriptions": [
"Description foo",
"Description bar"
]
}The latter two approaches are not recommended because they use editor-specific, non-standard properties. See Non-standard Properties for details.
There are several language servers that use SchemaStore:
Some language servers support non-standard properties. They include:
allowTrailingCommas
Used by: vscode-json-languageservice.
Whether trailing commas are allowed in the schema itself. Use the allowTrailingCommas field. See this PR if you wish to add this for your schema:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"allowTrailingCommas": true,
...
}defaultSnippets
Used by: vscode-json-languageservice.
markdownDescription
Used by: vscode-json-languageservice.
enumDescriptions
Used by: vscode-json-languageservice. See Documenting Enums for details.
markdownEnumDescriptions
Used by: vscode-json-languageservice. See Documenting Enums for details.
x-taplo
Used by: tamasfe/taplo.
x-taplo-info
Used by: tamasfe/taplo.
x-tombi-toml-version
Used by: tombi-toml/tombi. See this for details.
x-tombi-array-values-order
Used by: tombi-toml/tombi. See this for details.
x-tombi-array-values-order-by
Used by: tombi-toml/tombi. See this for details.
x-tombi-table-keys-order
Used by: tombi-toml/tombi. See this for details.
x-tombi-string-formats
Used by: tombi-toml/tombi. See this for details.
x-tombi-additional-key-label
Used by: tombi-toml/tombi. See this for details.
x-intellij-language-injection
Used by Intellij.
x-intellij-html-description
Used by Intellij.
x-intellij-enum-metadata
Used by Intellij. See Documenting Enums for details.
This repository uses the the code-owner-self-merge GitHub action to give project maintainers more control over their schema. It allows for:
- Mentioning a user when a schema is modified in a PR
- Enabling a user to merge a PR, so long it only modifies files that is "owned" by that user
See the CODEOWNERS file, the action configuration, and action documentation for more information.
After authoring a schema, you'll want to validate so it behaves as intended against popular validators.
This repository validations JSON Schemas in multiple ways:
- The default validation mode that is most stringent
- Checks schema to prevent any unexpected behaviors or silently ignored mistakes
- Fixing strict mode errors does not change validation results, it only serves to improve schema quality
- More info at Ajv Strict mode docs
Ajv non-strict mode
- Some rules are relaxed for the sake of brevity
- To validate under non-strict mode, add your schema to the
ajvNotStrictModefield in schema-validation.jsonc
- Helps catch errors within schemas that would otherwise be missed. This is a WIP
To actually run the validation checks, see How to validate a JSON Schema.
The catalog.json file is generally used by IDEs and language servers to determine which schemas apply to what files. Specifically:
- VSCode ignores this file see issue
- RedHat's YAML language server uses this file (see configuration)
- Taplo TOML language server uses this file (see this and this)
- Tombi: TOML language server uses this file (see this)
Sometimes, catalog.json is interpreted differently:
- With RedHat's YAML language server, the
fileMatchwill not work as expected if no.ya?mlextension is supplied with a custom file extension- See upstream issue
- See the schemastore issue issue for more info
And, generally, if a software supports multiple formats, stick with configuration file formats like JSON and avoid JavaScript. See this issue.
When adding glob patterns to fileMatch so language servers can auto-apply schemas, avoid adding generic patterns. For example, Hugo used to use config.toml:
This would not be accepted because the file detection would have too many false positives, conflicting with other frameworks and personal configurations. There are several ways to fix this:
- Modify the tool to read from a more specific file (Hugo now reads from
hugo.tomlas well) - Omit
fileMatchor set it to an empty array (which still allows the user to manually select it) - Prepend a directory name to the pattern (e.g.
"**/micro/runtime/syntax/*.yaml")
Glob implementations vary in their support of various pattern constructs. Lean towards keeping it simple rather than concise.
For example, {...} alternations and some extended glob constructs can be written as multiple "simple" patterns instead.
- Used by VSCode's Red Hat YAML extension
- Used by VSCode's Even Better TOML extension
- More information here
- Used by VSCode's Tombi extension
- More information here
- Visual Studio proprietary
- Intellij proprietary
- vscode-langservers-extracted
- SchemaStore.nvim
Some common errors include:
When updating the working tree, you may suddenly come across issues with dependencies like the following:
$ node ./cli.js
node:internal/modules/esm/resolve:838
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'ajv' imported from .../schemastore/cli.js
at packageResolve (node:internal/modules/esm/resolve:838:9)
...
at ModuleJob._link (node:internal/modules/esm/module_job:132:49) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v23.0.0To fix dependencies it is recommended to run npm clean-install. The command npm install should work as well.
The pre-commit.ci action can "mysteriously" fail to automatically commit formatted files. This happens because the repository corresponding to the pull request branch is not owned by a user account. This constraint is detailed in GitHub's documentation.
To fix this, run the formatter manually:
npm run prettier:fixTo run Prettier on specific files, run:
# Run on a schema file
./node_modules/.bin/prettier --config .prettierrc.cjs --ignore-path .gitignore --write src/schemas/json/<schemaName.json>
# Run on test files
./node_modules/.bin/prettier --config .prettierrc.cjs --ignore-path .gitignore --write src/test/<schemaName>/Follow these instructions if you want to add the JSON schema file directly to this repository. If you want to keep the JSON schema hosted elsewhere, see How to add a JSON Schema that's self-hosted/remote/external.
When uploading a new schema file, make sure it targets a file that is commonly used or has potential for broad uptake.
First, clone the repository:
git clone https://github.com/SchemaStore/schemastore
cd schemastoreBe sure that NodeJS is installed. The minimum required NodeJS version is defined by the engines key in package.json. Now, install dependencies and run the new-schema task:
npm clean-install
node cli.js new-schemaYou will be prompted for the name of the schema. Once you enter your schema name, the task will:
- Create a new schema file at
src/schemas/json/<schemaName>.json - Create a positive test file at
src/test/<schemaName>/<schemaName>.json - Print a string for you to add to the Schema Catalog
If you do not wish to use the new-schema task, the manual steps are listed below 👇
Manual Steps
-
Create a schema file in
src/schemas/json/<name>.json:{ "$id": "https://json.schemastore.org/<schemaName>.json", "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": true, "properties": {}, "type": "object" } -
Add positive test files at
src/test/<schemaName>/<testFile>: (optional, but strongly recommended)File extensions
.json,.toml,.yml, and.yamlare supported. -
Add negative test files at
src/negative_test/<schemaName>/<testFile>(optional) -
Register your schema (in alphabetical order) in the schema catalog:
{ "description": "Schema description", "fileMatch": ["list of well-known filenames matching schema"], "name": "Friendly schema name", "url": "https://json.schemastore.org/<schemaName>.json" }
Finally, validate your changes. See How to Validate a JSON Schema for details.
You may wish to serve a schema from https://json.schemastore.org/<schemaName>.json, but keep the content of the schema file at a place you control (not this repository).
See this PR as an example. Simply register your schema in the schema catalog, with the url field pointing to your schema file:
{
"name": "hydra.yml",
"description": "ORY Hydra configuration file",
"fileMatch": [
"hydra.json",
"hydra.yml",
"hydra.yaml",
"hydra.toml"
],
"url": "https://raw.githubusercontent.com/ory/hydra/master/.schema/version.schema.json"
},First, clone the repository:
git clone https://github.com/SchemaStore/schemastore
cd schemastoreBe sure that NodeJS is installed. The minimum required NodeJS version is defined by the engines key in package.json.
Now, modify the schema you intend to modify. Schemas are located under src/schemas/json.
Finally, validate your changes. See How to Validate a JSON Schema for details.
Refer to this agripparc PR as an example. First, your schema names should be suffixed with the version number.
src/schemas/json/agripparc-1.2.jsonsrc/schemas/json/agripparc-1.3.jsonsrc/schemas/json/agripparc-1.4.json
Then, use the versions field to list each of them. Add the latest version to the url field:
{
"description": "JSON schema for the Agrippa config file",
"fileMatch": [".agripparc.json", "agripparc.json"],
"name": ".agripparc.json",
"url": "https://json.schemastore.org/agripparc-1.4.json",
"versions": {
"1.2": "https://json.schemastore.org/agripparc-1.2.json",
"1.3": "https://json.schemastore.org/agripparc-1.3.json",
"1.4": "https://json.schemastore.org/agripparc-1.4.json"
}
}Simply changing the url field in the schema catalog (as described here) is not enough. You must also:
- Keep the original schema files in the repository and point to your schema with
$ref - Add an entry under
skiptestso the remaining schema file isn't tested
See this PR for a full example.
$ref from schema_x.json to schema_y.json
- Both schemas must exist locally in SchemaStore.
- Both schemas must have the same draft (ex.
draft-07) schema_y.jsonmust haveidor$idwith this value"https://json.schemastore.org/schema_y.json"- In
schema_x.json, add ref toschema_y.json:"$ref": "https://json.schemastore.org/schema_y.json#..." - Within schema-validation.jsonc, in
"options": [], add an entry:{ "schema_x.json": {"externalSchema": ["schema_y.json"] } }- Note that all transitive schemas must be specified in
externalSchema
- Note that all transitive schemas must be specified in
This currently isn't possible. This is tracked by issue #2731.
To validate all schemas, run:
node ./cli.js checkBecause there are hundreds of schemas, you may only want to validate a single one to save time. To do this, run:
node ./cli.js check --schema-name=<schemaName.json>For example, to validate the ava.json schema, run node ./cli.js check --schema-name=ava.json
Note that <schemaName.json> refers to the filename that the schema has under src/schemas/json.
The coverage tool analyzes how thoroughly your schema's test files exercise its constraints. It runs 8 checks:
- Unused
$defs— flags$defs/definitionsentries not referenced by any$ref - Description coverage — flags properties missing a
description - Test completeness — checks that every top-level schema property appears in at least one positive test
- Enum coverage — checks that each enum value has positive test coverage and at least one invalid value in negative tests
- Pattern coverage — checks that each
patternconstraint has a matching and a violating test value - Required field coverage — checks that negative tests omit required fields
- Default value coverage — checks that positive tests include non-default values
- Negative test isolation — flags negative test files that test multiple unrelated violation types
Opting in: Add your schema to the coverage array in src/schema-validation.jsonc:
"coverage": [
{ "schema": "my-schema.json" },
{ "schema": "my-strict-schema.json", "strict": true }
]strict(default:false) — whentrue, coverage failures cause a non-zero exit code, enforced in CI.- Without
strict: true, the tool reports findings but does not fail CI.
Running locally:
node ./cli.js coverage --schema-name=my-schema.jsonCoverage is opt-in and runs in CI. Schemas with strict: true will block PRs on coverage failures. Schemas without strict get an advisory report only.
Note Please only do this if you must. Validating in strict mode catches many common errors by schema authors and improves schema quality.
Sometimes, the build fails due to a failed validation check. See a list of validation checks here. An error may look like:
>> compile | schemas/json/prefect-deploy.json (draft-07)(FullStrictMode)
>> Error: strict mode: use allowUnionTypes to allow union type keyword at "#/definitions/prefect_docker.deployments.steps.push_docker_image/properties/credentials" (strictTypes)To ignore most validation errors, you need to modify ./src/schema-validation.jsonc:
- If a strict error fails, you need to add your JSON Schema to the
ajvNotStrictModearray - If you are getting "unknown format" or "unknown keyword" errors, you need to add your JSON Schema to the
optionsobject - If you are using a recent version of the JSON Schema specification, you will need to add your JSON Schema to the
highSchemaVersionarray
Often, it is useful to extract a subschema into its own file. This can make it easier to write tests, find schemas pertaining to a particular project, and logically separate extremely large schemas. The partial- prefix makes it easier for SchemaStore developers and subschema consumers to identify that the schema is a subschema.
A subschema should be extracted to its own file based on the following rules:
- If a schema represents an existing project that could be its own file, then simply use that file for the "subschema". In other places,
$refthat file where appropriate. - If the schema cannot be its own file, then extracting the subschema may be an improvement
- For example, Poetry reads configuration only from
pyproject.toml'stool.poetrykey. Because the Poetry subschema is relatively complex and a large project, it has been extracted to its own file,partial-poetry.json.
- For example, Poetry reads configuration only from
- If the schema must exist locally to workaround issue #2731, then the subschema should be extracted
- In a top-level
$comment, you must add the date at which you copied the original. See #3526 for an example
- In a top-level
Use your best judgement; if the project or schema is small, then the drawbacks of extracting the subschema to its own file likely outweigh the benefits.
{ "name": "Hugo", "description": "Hugo static site generator config file", "fileMatch": ["config.toml"], // Avoid generic patterns. "url": "https://json.schemastore.org/hugo.json", }