Skip to content

Commit ec978c0

Browse files
committed
update notes about reference registration order
1 parent 0ef4757 commit ec978c0

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

.jekyll-metadata

4.05 KB
Binary file not shown.

_docs/schema/basics.md

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -460,33 +460,10 @@ In _JsonSchema.Net_ this sibling-keyword behavior is controlled by the dialect t
460460

461461
In order to resolve references more quickly, *JsonSchema.Net* maintains two registries for all schemas and identifiable subschemas that it has encountered. The first is a global registry, and the second is a local registry that is contained in the options and is passed around on the build context. If a schema is not found in the local registry, it will automatically search the global registry.
462462

463-
A `JsonSchema` instance will automatically register itself with the local registry during the build step. Generally, build order is important. You want to build dependencies first.
463+
A `JsonSchema` instance will automatically register itself with the local registry during the build step. Reference resolution can occur at two points: as the final stage of building and as the first step of evaluation. Each schema keeps track of whether it has been fully resolved, so the check at evaluation time is incurred at most once.
464464

465-
For example, given these two schemas
466-
467-
```json
468-
{
469-
"$id": "http://localhost/my-schema",
470-
"type": "object",
471-
"properties": {
472-
"refProp": { "$ref": "http://localhost/random-string" }
473-
}
474-
}
475-
476-
{
477-
"$id": "http://localhost/random-string",
478-
"type": "string"
479-
}
480-
```
481-
482-
You must build `random-string` before you build `my-schema`.
483-
484-
```c#
485-
var randomString = JsonSchema.FromFile("random-string.json");
486-
var mySchema = JsonSchema.FromFile("my-schema.json");
487-
```
488-
489-
Now _JsonSchema.Net_ will be able to resolve the reference.
465+
> The check before evaluation was introduced with v8.0.4 to enable build/registration in any order.
466+
{: .prompt-tip }
490467

491468
_JsonSchema.Net_ will automatically handle reference loops, where one schema references another in such a way that some later reference eventually references the first.
492469

0 commit comments

Comments
 (0)