You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an attempt to simplify dereferencing refs and address issues
exposed by new json-schema-test-suite tests. The main thing here is
giving schema objects a `base_uri` that's used when resolving ids (and
as the initial base URI for instances). Child schemas use the `ref_uri`
that was used to resolve them as their `base_uri` in order to get nested
refs and ids to resolve properly.
More details about specific issues:
- `$id` is ignored when `$ref` is present (`instance.base_uri` is
updated after `validate_ref`), because `$ref` isn't supposed to take
sibling `$id` values into account. `@base_uri` handles nested refs.
Exposed by: json-schema-org/JSON-Schema-Test-Suite#493
- JSON pointers are evaluated relative to the ref URI. Previously,
pointers were always evaluated using the root schema. Now they're
evaluated relative to the schema with a matching `$id` (usually
nearest parent with an `$id`; or specific id (see below); default is
root).
Exposed by: json-schema-org/JSON-Schema-Test-Suite#457
- JSON pointers are evaluated for id refs. This allows a ref to look up
a schema by `$id` and then apply a JSON pointer to use a subschema.
This uses the same logic as above. The important part is removing the
fragment from `ref_uri` if it's a JSON pointer so that the lookup in
`ids` works properly. The fragment is kept if it's not a JSON pointer
to support location-independent ids.
Exposed by: json-schema-org/JSON-Schema-Test-Suite#578
- JSON pointer refs are always joined with the base URI. I [started
handling them][0] separately because of an [issue][1] with invalid
URIs. But now I think that was incorrect and that fragment pointers
need to be encoded properly for URIs. The [specification says][2]:
> In all cases, dereferencing a "$ref" reference involves first
> resolving its value as a URI reference against the current base URI.
- Empty fragments are removed in `join_uri` to have consistent URIs to
lookup in `ids`. Meta schemas, for example, have empty fragments in
their top-level ids (eg, `http://json-schema.org/draft-07/schema#`)
and removing the JSON pointer fragments causes them not to be found.
[0]: b91115e
[1]: #54
[2]: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-01#section-8.3.2
0 commit comments