Open dotlambda opened 1 year ago
This might be caused by a bug in jsonschema related to resolving JSON pointers with empty strings.
Using jsonschema 4.18.4 and referencing 0.30.0:
from jsonschema.validators import RefResolver
doc = {"": 0}
resolver = RefResolver("urn:foo", doc)
with resolver.resolving("#/") as resolved:
# resolves to {"": 0}, but should resolve to 0
# as per https://datatracker.ietf.org/doc/html/rfc6901#section-6
print(resolved)
The new referencing library that replaces the RefResolver works correctly however:
import referencing
import referencing.jsonschema
doc = {"": 0}
resource = referencing.Resource.from_contents(doc, default_specification=referencing.jsonschema.DRAFT4)
registry = referencing.Registry().with_resource("urn:foo", resource)
resolver = registry.resolver_with_root(resource)
resolved = resolver.lookup("#/")
# resolves to 0 correctly
print(resolved.contents)
With RefResolver being deprecated I'm not sure this will get fixed.
Unfortunately porting jsonmerge from RefResolver to referencing is not trivial either.
I'm trying to merge the following two files:
using the default strategy but am getting