Skip to content

Commit

Permalink
Merge pull request #1326 from bkueng/yaml_parsing_link
Browse files Browse the repository at this point in the history
docs: add link to check-jsonschema for how to handle generic yaml parsing
  • Loading branch information
Julian authored Jan 20, 2025
2 parents 51506b9 + 4f3a664 commit d557a26
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 d557a26

Please sign in to comment.