jsonschema icon indicating copy to clipboard operation
jsonschema copied to clipboard

Make it easier to create ref resolvers that don't do any remote lookup

Open jaredgrubb opened this issue 5 years ago • 2 comments

I enjoy using the $ref stuff (and $id) but I really never want my validators to actually access the network. I used a RefResolver instance to map some schemas together, but I can't figure out how to permanently disable actual network access (and only use the local store provided).

I looked through the sources and didn't see anything obviously. If this is already possible, maybe it'd be worth a FAQ entry or something?

jaredgrubb avatar May 26 '20 00:05 jaredgrubb

It's possible, though not easily and not in a great way. Doing so more easily is part of python-jsonschema/referencing#3. Happy to keep this open as a way to track the request individually though, it's a common request to make this easier. The test suite for this library itself in fact needs this to ensure it doesn't make remote requests while running.

Julian avatar Jun 06 '20 17:06 Julian

@jaredgrubb Maybe the PR python-jsonschema/jsonschema#717 could solve your problem.

willson-chen avatar Aug 06 '20 07:08 willson-chen

Hello there!

This, along with many many other $ref-related issues, is now finally being handled in #1049 with the introduction of a new referencing library which is fully compliant and has APIs which I hope are a lot easier to understand and customize.

The next release of jsonschema (v4.18.0) will contain a merged version of that PR, and should be released shortly in beta, and followed quickly by a regular release, assuming no critical issues are reported.

The new APIs do not have this bad behavior -- they don't make HTTP requests by default!

If you still care to, I'd love it if you tried out the beta once it is released, or certainly it'd be hugely helpful to immediately install the branch containing this work (https://github.com/python-jsonschema/jsonschema/tree/referencing) and confirm. You can in the interim find documentation for the change in a preview page here.

I'm going to close this given it indeed seems like it is addressed by #1049, but feel free to follow up with any comments. Sorry for the delay in getting to these, but hopefully this new release will bring lots of benefit!

Julian avatar Feb 23 '23 09:02 Julian