New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lookup references from referenced file #485
Comments
I encountered the same issue. I think its because the child is not stored as an individual Resource in the Registry, which makes that in-file references are taken to be relative to the main schema, instead of the child schema. I created a solution that allows referencing by id, instead of filename, and preload all sources in the registry. See pull request #946 Its not exactly solving the issue caused by in-file references in a child, but by converting all reference from reference by filename to reference by $id, the problem is prevented. You could actually use the filename as the id (by defining an $id parameter in each file), but that might be a bit confusing. As an extension to my solution, all files could be added to the registry with a uri derived from the relative file location from the main source. Currently, all files are registered by the exact filepath provided, so its not attempted to construct the relative path between the main source an all other sources. For some common situations (e.g. all files in the same folder), its relatively simple, but to make a reliable and robust implementation, its required to all paths in some canonical form, and perform all file matching on these canonical names. This Would probably require modifications to package referencing, which is out of scope for me. |
I try to understand better the design choices made in the current implementation of the If this is true, one way to solve this, is to implement the same type of logic in the Or would there be a more localized solution to support relative references from referenced files? |
I found, that looking up $defs in a file referenced by another file uses the original resolver and the uri designator does not get prefixed.
Attached a minimal example.
Here the most usefull part of the exception:
referencing.exceptions.PointerToNowhere: '/$defs/def_child' does not exist within {'$schema': 'https://json-schema.org/draft/2019-09/schema', 'type': 'object', 'properties': {'child': {'$schema': 'https://json-schema.org/draft/2019-09/schema', '$defs': {'def_child': {'type': 'object'}}, 'allOf': [{}]}}, 'required': ['child']}
minimal_example.zip
The text was updated successfully, but these errors were encountered: