Skip to content
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

RFC: Multidoc YAML support #378

Open
aaronnickovich opened this issue Nov 1, 2023 · 2 comments
Open

RFC: Multidoc YAML support #378

aaronnickovich opened this issue Nov 1, 2023 · 2 comments

Comments

@aaronnickovich
Copy link

I fell in love with LSPs using schemastore so I am trying to convince my devops team to use this project in their CI/CD for schema validation.

My target files was almost exclusively multidoc YAML files so I modified the cli.js and parser.js to support multidoc YAML files.

Would you want this functionality contributed back? If so, I can discuss further and open a PR.

npm run v8r catalog-info.yaml

> v8r@2.1.0 v8r
> src/index.js catalog-info.yaml

ℹ No config file found
ℹ Processing ./catalog-info.yaml
ℹ Found schema in https://www.schemastore.org/api/json/catalog.json ...
ℹ Validating ./catalog-info.yaml against schema from https://json.schemastore.org/catalog-info.json ...
ℹ parsed yaml file as a multi-yaml doc
✔ ./catalog-info.yaml[0] is valid

✔ ./catalog-info.yaml[1] is valid
@chris48s
Copy link
Owner

chris48s commented Nov 1, 2023

It is not a use-case I am super familiar with, but happy to look at a PR.

Just thinking through some considerations: We would have to assume that all of the yaml documents in a given file conform to the same schema. I don't think we could deal with a situation where a file contains multiple yaml documents and they need to be validated against different schemas. At the moment everything is based on one schema being used to validate a file. I think that's a reasonable limitation.

@aaronnickovich
Copy link
Author

Yes, customizing per-doc in a YAML file doesnt fit the philosophy of the schemastore which is based on the filename, path, and extension.

Also, most of the yaml schemas I see in the schemastore are supposed to be a single doc so it's an edge-case, of course.

For context, I am piloting an instance of https://backstage.io which is just a catalog of people, teams, software, and apis.
Each team just maintains their own catalog-info.yaml file and each can contain somewhere between 1 - 6 docs. An example is here:
https://github.com/backstage/backstage/blob/master/packages/catalog-model/examples/acme/org.yaml

Anways, I'll work on it and open a PR in a few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants