Skip to content

Latest commit

 

History

History
60 lines (51 loc) · 1.7 KB

frame.markdown

File metadata and controls

60 lines (51 loc) · 1.7 KB

Framing

jsonschema frame <schema.json> [--verbose/-v]

To evaluate a schema, an implementation will first scan it to determine the dialects and keywords in use, walk over its valid subschemas, and resolve URI references between them. We refer to this reconnaissance process as "framing". The JSON Schema CLI offers a frame command so you can "see through the eyes" of a JSON Schema implementation previous to the evaluation step. This is often useful for debugging purposes.

Examples

For example, consider the following schema that includes a local reference:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com",
  "$ref": "#/$defs/string",
  "$defs": { "string": { "type": "string" } }
}

The framing process will result in the following entries that capture the reference:

...
(LOCATION) URI: https://example.com#/$defs/string/type
    Schema           : https://example.com
    Pointer          : /$defs/string/type
    Base URI         : https://example.com
    Relative Pointer : /$defs/string/type
    Dialect          : https://json-schema.org/draft/2020-12/schema
...
(LOCATION) URI: https://example.com#/$ref
    Schema           : https://example.com
    Pointer          : /$ref
    Base URI         : https://example.com
    Relative Pointer : /$ref
    Dialect          : https://json-schema.org/draft/2020-12/schema
...
(REFERENCE) URI: /$ref
    Type             : Static
    Destination      : https://example.com#/$defs/string
    - (w/o fragment) : https://example.com
    - (fragment)     : /$defs/string

Frame a JSON Schema

jsonschema frame path/to/my/schema.json