-
-
Notifications
You must be signed in to change notification settings - Fork 8
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 for Multiple YAML Documents #344
Comments
Currently the plugin handles multiple documents as an array. |
The majority I know offer two functions. One to deserialize a single document and another to deserialize multiple (returning some kind of list). The problem here is that a JSON schema is meant to describe a single document, but in YAML we can have multiple documents in a single file. I think that the library should always assume multiple documents in a single YAML file and validate each separately. A JSON schema cannot disable this YAML functionality anyway. |
So multiple documents are treated as a list (array), right? But does the schema expect object? |
Each document has its own schema. It needs to be thought of like a tar file. One file containing many others. Hence, a schema applies per document within a YAML file, not per YAML file. I don't think it's very widespread. Using a single file with multiple documents always results in unnecessary merge conflicts. The only one case I have at hand where it seems to be a thing is Backstage's Each document would need to be treated like a separate file and validated individually. This begs the question of how to choose the schema. Obviously it's desirable to have the ability for a single schema to apply to all documents within. This can be achieved via the ESlint config, and via YAML comments (once implemented). Individual schemas can be achieved via a That said, I've never seen the need for individual schemas, hence, having only one would IMHO be good enough. Still, it's how YAML works... |
Sorry for the late reply. |
YAML has support for multiple documents via the document start
---
and (optional) document end...
markers. Trying to validate a YAML with multiple documents currently fails with:The text was updated successfully, but these errors were encountered: