Skip to content

Commit d42581c

Browse files
committed
add section to specify behavior for failed reference resolution
1 parent de65b76 commit d42581c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

jsonschema-core.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,35 @@ behave correctly under implementations that attempt to use any reference target
15611561
as a schema. However, this behavior is implementation-specific and MUST NOT be
15621562
relied upon for interoperability.
15631563

1564+
#### Failure to resolve references
1565+
1566+
If for any reason a reference cannot be resolved, the evaluation MUST halt and
1567+
return an indeterminant result. Specifically, it MUST NOT return a passing or
1568+
failing validation result or any annotations. Instead it MUST inform the
1569+
consuming application or user of the evaluation failure via other means. It is
1570+
RECOMMENDED that implementations utilize native functionality for this purpose,
1571+
such as, but not limited to, raising an exception or other error.
1572+
1573+
In the cases where optimizations are enabled and a schema containing a
1574+
non-resolvable reference would be skipped, as in the example below, behavior is
1575+
implementation-defined.
1576+
1577+
```json
1578+
{
1579+
"anyOf": [
1580+
true,
1581+
{ "$ref": "https://json-schema.org/does-not-exist" }
1582+
]
1583+
}
1584+
```
1585+
1586+
Here, an optimized evaluation may recognize that `/anyOf/0` will satisfy the
1587+
`anyOf` constraint, regardless of the validation result of `/anyOf/1`, and so
1588+
`/anyOf/1` may be skipped altogether.
1589+
1590+
However, an unoptimized evaluation of this schema (for example one that expects
1591+
all annotation results), would result in a resolution failure.
1592+
15641593
### Associating Instances and Schemas
15651594

15661595
#### Usage for Hypermedia {#hypermedia}

0 commit comments

Comments
 (0)