Skip to content

Easy use of the JSON SchemaStore from Python, as a referencing.Registry

License

Notifications You must be signed in to change notification settings

python-jsonschema/schemastore

Repository files navigation

schemastore.py

A collection of all JSON Schemas from the schemastore.org catalog, installable so they may be used without internet access.

Installation

Use your favorite package manager, e.g. via:

$ uv pip install schemastore

or

$ pip install schemastore

Usage

Schemas are made usable as a referencing.Registry. It is available as:

import schemastore
registry = schemastore.registry()

and use any of the API from the aforementioned referencing package to make use of the schemas, such as:

print(registry.get_or_retrieve("https://json.schemastore.org/github-action.json").value)

though more typically you will use the registry alongside a JSON Schema validator such as those provided by the jsonschema library:

import jsonschema
import schemastore


# Validate whether the string "foo" is a valid GitHub actions workflow (it is not.)
jsonschema.validate(
    '"foo"',
    {"$ref": "https://json.schemastore.org/github-action.json"},
    registry=schemastore.registry(),
)