-
Notifications
You must be signed in to change notification settings - Fork 40
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
Support yaml files with multiple documents #222
Comments
It seems to run with the following changes #223 |
Thanks for raising this, and sharing the initial crack at an implementation in #223 ! One thing which we'd need to consider is that a document can contain a top-level array, like - foo
- bar and you can have a schema which expects/requires this. I'm also going to have to think about the output, and how it could be clarified in such a case. I'm receptive to this, especially with someone putting in the effort to show how it could be done (again, thanks!) but need to think harder about it to decide what is right. |
Any update on this? 😅 Reporting wise IMHO |
I haven't been able to make time for it, unfortunately. My time for check-jsonschema has been spent on other issues, but it's on my radar as a "would be nice". At It's good to know that The part that's not clear to me, circling back to this thread, is what the CLI interface should be for this to disambiguate the following two files: # list.yaml
- foo: bar
- bar: baz vs # multiobject.yaml
---
foo: bar
---
bar: baz And how should it behave if you run this?
I think the right thing is that all YAML files be treated as multi-item. Is that all we need? I'm trying to make sure we can describe the behavior well, and it should be easy enough to write code to that spec. |
Actually, @sirosen I think about this a bit differently. To me, The former is 1 "object" (?) of "root type" List, with an "element type" of "something than can be The latter however is 2 (!) "objects" of the same "root type" as what's the "element type" of the former. Does this make sense? So the way I understand things, a YAML with multiple documents is just a list of N instead of 1 "roots", which one considers to (have to be) "of the same type" for such a validation. When this will be implemented, I could (try to) validate e.g. this with it. |
Yes, that matches my understanding as well. One file contains a single document, a list, while the other is a file containing two documents, each of which is an object. I haven't looked at implementing this in a while, but IIRC the ruamel.yaml interface for loading multiple documents makes these hard to distinguish. As long as we don't "flatten" those two files to be identical once loaded, we can implement some change -- probably without issue. |
A kludge: yq ea -j '[.]' document-stream.yaml \
| check-jsonschema --schemafile schema.json - |
Is there any interest in adding support for checking yaml files with multiple documents in them? That is:
catalog-info.yaml:
Ref https://yaml.org/spec/1.2.2/#22-structures
The text was updated successfully, but these errors were encountered: