Skip to content

Commit 51959b9

Browse files
committed
Explain how to use jsonschema inspect for $schema
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 55308a3 commit 51959b9

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

content/2020-12/core/schema.markdown

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,47 @@ command. For example:
6666
$ jsonschema metaschema my-schema.json
6767
```
6868

69+
To debug the role of the `$schema` keyword on a schema (particularly schemas
70+
with embedded resources), try the [`jsonschema
71+
inspect`](https://github.com/sourcemeta/jsonschema/blob/main/docs/inspect.markdown)
72+
command. This command prints detailed information about each schema resource,
73+
subschema, location, and reference present in the schema. For example:
74+
75+
```sh
76+
$ jsonschema inspect schema.json
77+
(RESOURCE) URI: https://example.com/schema
78+
Type : Static
79+
Root : https://example.com/schema
80+
Pointer :
81+
Base : https://example.com/schema
82+
Relative Pointer :
83+
Dialect : https://json-schema.org/draft/2020-12/schema
84+
Base Dialect : https://json-schema.org/draft/2020-12/schema
85+
Parent : <NONE>
86+
Instance Location :
87+
88+
...
89+
90+
(SUBSCHEMA) URI: https://example.com/schema#/properties/foo
91+
Type : Static
92+
Root : https://example.com/schema
93+
Pointer : /properties/foo
94+
Base : https://example.com/schema
95+
Relative Pointer : /properties/foo
96+
Dialect : https://json-schema.org/draft/2020-12/schema
97+
Base Dialect : https://json-schema.org/draft/2020-12/schema
98+
Parent :
99+
Instance Location : /foo
100+
101+
...
102+
103+
(REFERENCE) ORIGIN: /$schema
104+
Type : Static
105+
Destination : https://json-schema.org/draft/2020-12/schema
106+
- (w/o fragment) : https://json-schema.org/draft/2020-12/schema
107+
- (fragment) : <NONE>
108+
```
109+
69110
## Examples
70111

71112
{{<schema `A schema described by the JSON Schema 2020-12 official dialect`>}}

0 commit comments

Comments
 (0)