Skip to content
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

Use the new 'referencing' implementation in 'jsonschema' #289

Merged
merged 9 commits into from
Aug 8, 2023

Conversation

sirosen
Copy link
Member

@sirosen sirosen commented Jul 29, 2023

This change drops py3.7 (not supported by 'referencing' and EOL) and switches the implementation to 'referencing'.

Because the way that $ref retrieval works has changed, it unlocks the possibility of having .yaml schemas which refer to other .yaml files as subschemas, etc. This has been implemented, rather than retaining the prior "reject with a warning" behavior for YAML, TOML, and JSON5.

I'd like to see this work in CI at the very least and potentially add some newer test cases to see if I can break it. In particular, there's a bit of mushy $id and schema_uri handling, which I'd like to check with responses.

There's a new implementation of ref resolution in newer versions of
'jsonschema'. Upgrade to use this, plus add support for loading YAML,
JSON5, and TOML schemas as references (so long as they have the
filetype suffixes which make them easily detectable).
`referencing` does not support 3.7, which means that supporting 3.7
would start to require separate compatibility code precisely when it
has just reached EOL (4 weeks ago at time of writing).

Drop 3.7 and move the 'mindeps' builds to 3.8
Also setup a pyright tox environment for testing and usage.
URL joining needs to be done between any relative ref paths and the
base URI. This was not correct, as revealed by a new testcase.
After fixing, this revealed that the local file loading was somewhat
indirect in a way that it no longer needs to be, so local file
handling in the ref resolver has been refactored as well.
sirosen and others added 4 commits August 2, 2023 22:50
Relative dyanicRef usage was resolved incorrectly in the prior
implementation, but it has been fixed by correct use of `referencing`.
Test to ensure that this case is satisfied.

See also: #293
Ensure that the `$id` and retrieval URI handling are both done
correctly. JSON Schema specifies that `$id` has precedence, so one of
the tests confirms that preference.
The retrieval URI was internally called the 'ref base' or 'schema
URI', both of which suggest that it is definitively the base URI used
for reference resolution. This makes it confusing that adjusting this
URI might not change the base URI used.

Instead, call it properly 'retrieval URI'.

Base URI is newly introduced inside of the retrieve callback, after
receiving both the `$id` (if any) and the retrieval URI.
@sirosen sirosen merged commit 76b19fe into main Aug 8, 2023
36 checks passed
@sirosen sirosen deleted the use-referencing branch August 8, 2023 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant