Replies: 4 comments 1 reply
-
I did try just taking the |
Beta Was this translation helpful? Give feedback.
-
I'm on vacation so it will likely be a few weeks before I look at what you wrote, but I suspect you're probably in the first case on the page, namely this where you can simply read each of your files and populate a registry with them ahead of time. |
Beta Was this translation helpful? Give feedback.
-
According to the jsonschema documentation, starting with version 4.18.0, the RefResolver class has been deprecated. Instead, it is proposed to use the referencing library, which provides more compatible reference methods and more flexible APIs for customization. However, despite the availability of detailed documentation on referencing, it can be difficult to immediately figure out how to replace the simple case of using RefResolver. For your case where you just need to jsonschema.validate knew where to look for schemas, you can use the JsonRefs context manager, which automatically adjusts the reference for the current context. Here is an example of how this can be implemented: import json schema_dir = '/path/to/your/schemas/' with JsonRefs(refs_resolver=lambda ref: open(schema_dir + ref)) as refs: |
Beta Was this translation helpful? Give feedback.
-
thanks for the info folks, I will try to get it going using those pointers. |
Beta Was this translation helpful? Give feedback.
-
While running tests on https://pagure.io/fedora-qa/os-autoinst-distri-fedora , I noticed a deprecation warning:
So I went to look at the docs to try and resolve it. All we are doing is using a
RefResolver
which specifies a local file path to resolve references: the project has a directory with a bunch of schema files in it, and some of them reference others of them. All I need is forjsonschema.validate
to know that it should just look in the same directory when resolving these references, so all we do is find that directory and pass it as the first argument to theRefResolver
instance.The deprecation notice points me to https://github.com/python-jsonschema/referencing , which explains the referencing library in great detail but really doesn't help me figure out how the heck to use it to replace this very simple
RefResolver
usage. Googling around brings me to https://python-jsonschema.readthedocs.io/en/latest/referencing/ , which likewise goes into a ton of confusing detail on other scenarios but doesn't seem to provide any obvious help for mine. It even has a "Migrating from RefResolver" section, which also does not seem to cover this scenario at all.It'd be great if any of these docs helped me figure out how to survive this deprecation :| thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions