Skip to content

Commit d5914b2

Browse files
committed
initial scopes updates
1 parent 8af8969 commit d5914b2

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

specs/jsonschema-core.md

+24-11
Original file line numberDiff line numberDiff line change
@@ -450,21 +450,31 @@ further change the assertion result.
450450

451451
While most JSON Schema keywords can be evaluated on their own, or at most need
452452
to take into account the values or results of adjacent keywords in the same
453-
schema object, a few have more complex behavior.
453+
schema object, a few have more complex behavior. This behavior is generally
454+
governed by the scope of the keyword.
455+
456+
This specification defines two such scopes: lexical and dynamic.
457+
458+
#### Lexical Scope
454459

455460
The lexical scope of a keyword is determined by the nested JSON data structure
456461
of objects and arrays. The largest such scope is an entire schema document. The
457462
smallest scope is a single schema object with no subschemas.
458463

459-
Keywords MAY be defined with a partial value, such as a IRI reference, which
460-
must be resolved against another value, such as another IRI reference or a full
461-
IRI, which is found through the lexical structure of the JSON document. The
462-
`$id`, `$ref`, and `$dynamicRef` core keywords, and the "base" JSON Hyper-Schema
463-
keyword, are examples of this sort of behavior.
464+
Keywords MAY be defined with a partial value which must be resolved against
465+
another value found within the lexical structure of the JSON document. The
466+
`$id`, `$schema`, and `$ref` core keywords, and the `base` JSON Hyper-Schema
467+
keyword, are some such keywords. For example, an `$id` keyword found in an
468+
embedded schema resource may have a value that is a relative IRI. This value
469+
must be resolved against another `$id` keyword found in an ancestor subschema,
470+
or the root schema, to produce an absolute IRI which fully identifies that
471+
embedded schema resource.
464472

465473
Note that some keywords, such as `$schema`, apply to the lexical scope of the
466474
entire schema resource, and therefore MUST only appear in a schema resource's
467-
root schema.
475+
root object.
476+
477+
#### Dynamic Scope
468478

469479
Other keywords may take into account the dynamic scope that exists during the
470480
evaluation of a schema, typically together with an instance document. The
@@ -894,8 +904,10 @@ If this IRI identifies a retrievable resource, that resource SHOULD be of media
894904
type `application/schema+json`.
895905

896906
The `$schema` keyword SHOULD be used in the document root schema object, and MAY
897-
be used in the root schema objects of embedded schema resources. When the
898-
keyword appears in a non-resource root schema object, the behavior is undefined.
907+
be used in the root schema objects of embedded schema resources. This keyword
908+
MUST NOT appear in a subschema that is not also the root object of a schema
909+
resource (see {{id-keyword}} for more information regarding defining embedded
910+
schema resources.)
899911

900912
Values for this property are defined elsewhere in this and other documents, and
901913
by other parties.
@@ -917,8 +929,9 @@ to establish a base IRI in order to resolve the reference.
917929
#### The `$id` Keyword {#id-keyword}
918930

919931
An `$id` keyword in a schema or subschema identifies that schema or subschema as
920-
a distinct schema resource. The value for this keyword MUST be a string, and
921-
MUST represent a valid IRI reference without a fragment.
932+
a distinct schema resource and defines a new lexical scope. The value for this
933+
keyword MUST be a string, and MUST represent a valid IRI reference without a
934+
fragment.
922935

923936
When the value of this keyword is resolved against the current base IRI, the
924937
resulting absolute IRI then serves as the identifier for the schema resource and

0 commit comments

Comments
 (0)