Clarify in the FAQ that the CLI parses schemas and instances as JSON
Problem
The FAQ's "Can jsonschema be used to validate YAML, TOML, etc.?" answer says the library "doesn't actually deal directly with JSON at all", and describes remote $ref resolution as "a single notable exception" to that.
That is not quite accurate. The (deprecated) jsonschema command line interface also parses JSON itself, for both the schema and any instance files, as well as standard input:
jsonschema/cli.pyin_Outputter.load, used for every instance file argumentjsonschema/cli.pyinmain, for the instance read fromstdin
So a document that is not valid JSON fails to parse, even when the file is named with a .yaml or .yml extension. That is a natural thing for someone following this FAQ to try, and the current wording does not warn them.
Solution
Note the CLI as a second case where the library has to read JSON, and point readers who want to validate YAML or TOML at deserializing the documents themselves before passing them in.
The behavior itself is unchanged; this only corrects the documentation. Two tests in jsonschema/tests/test_cli.py pin the behavior being documented so the FAQ cannot silently drift from what the CLI actually does, one for the instance and one for the schema, each under both .yaml and .yml names.
Why an issue and not a pull request
I was not able to open a pull request: the GitHub token available to me reports push: false on this repository, and both gh pr create and the REST POST /repos/python-jsonschema/jsonschema/pulls endpoint fail for this account. Creating a pull request on a repository I do have access to works, so this is specific to opening one against upstream.
The change is two files, 48 insertions and 2 deletions, and is ready to apply. A ready-to-use link, which will create the pull request if you have push access:
https://github.com/pasmud/jsonschema/compare/main...pasmud:gsz/clarify-faq-cli-parses-json?expand=1
The branch gsz/clarify-faq-cli-parses-json is pushed to the fork pasmud/jsonschema. If you would prefer, the diff is small enough to apply by hand from the branch.
On the deeper change
Actually teaching the CLI to accept YAML or TOML would be a larger, user-facing change to a deprecated interface, and the README already directs CLI users to check-jsonschema, which handles those formats. So this stays scoped to making the existing documentation accurate.
Verification
jsonschema.tests.test_cli: 52 tests, all passing.- Full suite: 8531 tests, 0 failures, 703 skipped.
ruff check jsonschema/: all checks passed.- Documentation doctests (
sphinx-build -b doctest): 77 tests, 0 failures. - The two new tests were confirmed to be meaningful: replacing
json.loadwith a YAML parser in_Outputter.loadmakes 11 tests in the module fail, and restoring it makes them pass again.