Innablr / revolver

AWS Powercycle Facility
MIT License
2 stars 3 forks source link

Create a schema for editors when modifying the config YAML #429

Closed lyricnz closed 2 months ago

lyricnz commented 3 months ago

This would be useful for auto-completion, valid options, etc.

lyricnz commented 3 months ago

I generated a JSON schema from our Zod schema using https://github.com/StefanTerdell/zod-to-json-schema myschema.json

Then added a comment at the top of a config yaml file:

# yaml-language-server: $schema=myschema.json

Which gave me autocomplete, and warnings about missing mandatory fields!

image
lyricnz commented 3 months ago

See https://github.com/redhat-developer/yaml-language-server?tab=readme-ov-file#using-inlined-schema

lyricnz commented 3 months ago

This helps avoid errors, since the schema can point out invalid attributes.

image

Of course, @abukharov wants to be able to add random stuff to the YAML - so maybe there needs to be an option for that (or ignore the warnings)