jsonschema identify <schema.json> [--relative-to/-t <uri>] [--verbose/-v]
A schema may be associated with a URI through the use of keywords like $id
or
its predecessor id
. This command takes a JSON Schema as input and prints to
standard output the identifying URI of the schema. This command heuristically
handles the case where you don't know the base dialect of the schema. For
convenience, you may provide a base URI to resolve the schema identity URI
against.
For example, consider the following schema identified as
https://example.com/foo/bar
.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/foo/bar"
}
We can interact with the identifier URI of this schema as follows:
$ jsonschema identify schema.json
https://example.com/foo/bar
$ jsonschema identify schema.json --relative-to "https://example.com"
/foo/bar
jsonschema identify path/to/my/schema.json
jsonschema identify path/to/my/schema.json --relative-to "https://example.com"