python-jsonschema / python-jsonschema/check-jsonschema
Support yaml files with multiple documents
Open
Nobody has claimed this yet.
enhancement
needs-investigation
- Dominant language
- Python
- Stars
- 341
- Forks
- 71
- Avg merge
- 15d 20h
- Merged PRs (30d)
- 4
Description
Is there any interest in adding support for checking yaml files with multiple documents in them? That is:
catalog-info.yaml:
---
apiVersion: backstage.io/v1alpha1
kind: System
metadata:
name: example-system
spec:
owner: my-team
---
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: example-service
spec:
owner: my-team
system: example-system
❯ check-jsonschema --schemafile "https://json.schemastore.org/catalog-info.json" -v catalog-info.yaml
Several files failed to parse.
FailedFileLoadError: Failed to parse catalog-info.yaml
in "/Users/nikolark/.pyenv/versions/3.10.8/lib/python3.10/site-packages/check_jsonschema/instance_loader.py", line 31
>>> data: t.Any = self._parsers.parse_file(path, self._default_filetype)
caused by
ComposerError: expected a single document in the stream
in "<byte string>", line 2, column 1:
apiVersion: backstage.io/v1alpha1
^ (line: 2)
but found another document
in "<byte string>", line 8, column 1:
---
^ (line: 8)
in "/Users/nikolark/.pyenv/versions/3.10.8/lib/python3.10/site-packages/check_jsonschema/parsers/__init__.py", line 89
>>> return loadfunc(fp)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the file-loading path through instance_loader.py and parsers/init.py, which appear in the reported traceback. Run the supplied check-jsonschema command with the example catalog-info.yaml, then inspect how YAML is currently parsed. Done means multi-document YAML files can be checked without the single-document parse failure, with the relevant behavior covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, yaml
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100