Skip to content

Commit

Permalink
docs: add link to check-jsonschema for how to handle generic yaml par…
Browse files Browse the repository at this point in the history
…sing
  • Loading branch information
bkueng committed Jan 20, 2025
1 parent 51506b9 commit 4f3a664
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions docs/referencing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ Here for instance we retrieve YAML documents in a way similar to the `above <ref
JSON Schema is defined specifically for JSON, and has well-defined behavior strictly for Python objects which could have possibly existed as JSON.

If you stick to the subset of YAML for which this is the case then you shouldn't have issue, but if you pass schemas (or instances) around whose structure could never have possibly existed as JSON (e.g. a mapping whose keys are not strings), all bets are off.
For an example on how to handle that, have a look at the `parsers/yaml.py <https://github.com/python-jsonschema/check-jsonschema/blob/main/src/check_jsonschema/parsers/yaml.py>`_ file in the check-jsonschema repository.

One could similarly imagine a retrieval function which switches on whether to call ``yaml.safe_load`` or ``json.loads`` by file extension (or some more reliable mechanism) and thereby support retrieving references of various different file formats.

Expand Down

0 comments on commit 4f3a664

Please sign in to comment.