Skip to content

How can I resolve all references in a schema? #542

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

Closed
Zac-HD opened this issue Mar 21, 2019 · 5 comments
Closed

How can I resolve all references in a schema? #542

Zac-HD opened this issue Mar 21, 2019 · 5 comments
Labels
Enhancement Some new desired functionality

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Mar 21, 2019

I would like to take a schema that may have local or remote references, and return an equivalent schema that does not use any references at all. This would be really useful for hypothesis-jsonschema, but I have no idea how to do it with RefResolver - I can't tell from the docs whether this is even something it should do.

Maybe related to python-jsonschema/referencing#3? Any advice would be appreciated - I'd also be happy to e.g. ban remote references or local ids if that would help. I sketched an idea for the quick-and-dirty on python-jsonschema/hypothesis-jsonschema#6 but would prefer an upstream implementation if possible 😄

@Julian
Copy link
Member

Julian commented Mar 21, 2019

Will respond with more detail but probably related to #419 (and the latter is "doable" but not as easy as it should be so yeah definitely up for improvements here)

@handrews
Copy link

@Zac-HD if you don't specifically need it to be in Python, you might take a look at JSON Schema Ref Parser.

@maddanio
Copy link

Hmm, but this can't be doable for recursive references, right?

@Zac-HD
Copy link
Member Author

Zac-HD commented Aug 12, 2019

Hmm, but this can't be doable for recursive references, right?

Depends on your perspective - Python containers can contain themselves, so it would be perfectly possible to represent recursive schemas without an explicit $ref keyword.

It's probably more ergonomic to only resolve the non-recursive references though, since that would make it trivial to construct a DOS attack against naive code.

Recursive references are also - while not especially rare - less common than simple references, so non-recursive resolution would still be very helpful incremental step 😄

@Zac-HD
Copy link
Member Author

Zac-HD commented Jan 4, 2020

Closing in favor of python-jsonschema/hypothesis-jsonschema#28, since the canonicalisation I want isn't really useful for validators.

@Zac-HD Zac-HD closed this as completed Jan 4, 2020
Julian added a commit that referenced this issue Apr 29, 2022
060caae0d Merge pull request #467 from gene-hightower/strict-rfc-grammar
995932c74 Additional RFC-5321 Mailbox tests
637f0ac3e Merge pull request #542 from jdesrosiers/dyanmicref-no-bookending
87944e52e Merge pull request #543 from jdesrosiers/update-vocabulary-for-draft-next
07b90e3b5 Merge pull request #544 from frawa/list-typed-json
365349adc list typed-json in new Scala section
9d1efc27e Update vocabulary tests for draft-next
89f59caad Update dynamicRef tests for bookenending removal

git-subtree-dir: json
git-subtree-split: 060caae0dd58e34af0449baec1103606a0ef4977
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Some new desired functionality
Projects
None yet
Development

No branches or pull requests

4 participants