python-jsonschema / jsonschema

An implementation of the JSON Schema specification for Python
https://python-jsonschema.readthedocs.io
MIT License
4.58k stars 578 forks source link

Need a custom ref resolver #1225

Closed Honnegowda closed 6 months ago

Honnegowda commented 6 months ago

I have two folders per say /test1/schemas/test_jsons/ and /test2/schmeas/test_jsons/ and inside those folder I have test.json file and I have below json in /test2/schemas/wrapper_jsons test_wrapper_json =
{ "test_types": { "type": "array", "items": { "$ref": "../test_jsons/test.json", "type": "object" }, "uniqueItems": true, "minItems": 1 } } uri_root = 'file://test2/schemas/' resolver = jsonschema.RefResolver(uri_root, test_wrapper_json) I need a custom resolver that should look for json_file from /test1/schemas/test_jsons/ first, if file not found in that path then it should look for /test2/schmeas/test_jsons.