-
-
Notifications
You must be signed in to change notification settings - Fork 584
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
Schema with $id / id does not have the id automatically cached for $ref resolution #710
Comments
sample.json:
sample.schema:
Install jsonschema v3.2.0 and run the following command and this is what we see.
We expect the jsonschema treats the |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
@willson-chen Thank you for looking into it. I always use latest release tagged v3.2.0 in my code, because I found current master branch has its own issue. For example, in my sample.json, if I change |
@FuhuXia Yes, I also noticed this. It may take some time to look. After I installed v3.2.0 and cherry-picked the three commits from the PR #717, then executed the command For your reference. |
This comment was marked as off-topic.
This comment was marked as off-topic.
(Note to self): This seems to still occur, a minimal-er reproducer is: from jsonschema.validators import Draft4Validator, RefResolver
schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"organization": {
"id": "https://project-open-data.cio.gov/v1.1/schema/organization.json#",
"properties": {
"subOrganizationOf": {"$ref": "#"}
}
}
},
"properties": {"organization": {"$ref": "#/definitions/organization"}}
}
instance = {"organization": {"subOrganizationOf": {}}}
resolver = RefResolver.from_schema(schema)
resolver.resolve_remote = lambda *args, **kwargs: breakpoint()
Draft4Validator(schema, resolver=resolver).validate(instance) where we still hit Probably fixing this is dependent on having an API for flagging |
Hello there! This, along with many many other The next release of It looks from my testing like indeed this specific example works there! 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! |
544f7c3d Merge pull request #712 from otto-ifak/main 9dad3ebe Add tests for enum with array of bool 589a0858 Merge pull request #706 from marksparkza/unevaluated-before-ref 64d5cab9 Merge pull request #710 from spacether/patch-1 418cdbd6 Removes idea folder e0a9e066 Updates all other tests to mention grapheme/graphemes 69136952 Update minLength.json 4a2c61e8 Test unevaluatedItems|Properties before $ref git-subtree-dir: json git-subtree-split: 544f7c3df93b69f84f587b345f2835c380e43226
We have an all-in-one schema file, within which the property
subOrganizationOf
is referencing to its parentorganization
by"$ref": "#"
. But when validators.py hits this $ref, it tries to follow the url in the id and fetch external url https://project-open-data.cio.gov/v1.1/schema/organization.json. If the url is out-dated, it raise RefResolutionError(exc).We are expecting validators stays with local definition, not relies on external url to validate this recursive self-referenced definition.
The text was updated successfully, but these errors were encountered: