Open bollwyvl opened 1 month ago
I would be very happy to accept a PR! Would you be able to make one?
This is actually going fairly well, but one of my assumptions was poor, and it turns yls
does not in fact support an explicit $schema
.
As having to specify a long URI twice is worse than the status quo, I'll hold on opening the PR here until I get some feedback on https://github.com/redhat-developer/yaml-language-server/pull/970.
elevator pitch
Add
#/{$id,$schema,title,description}
to the top-level schema object, and a top-level#/properties/$schema
to be validated in instance documents.motivation
The current guidance of using tool-specific comment annotation, pointing at a "hot" file on a repo to get a reasonable developer experience seems like a backslide into the Bad Old Days of
# [meta]
selectors.Using a standards-based representation of this metadata, tools would not have to parse magic comments to determine what schema should be used to validate a given instance.
While
$schema
only strictly has to be an identifier, making it a locator would mean that it could resolve directly, such that it would work withyaml-language-server
out of the box, and other tools would not require a comment-aware parser to use the data programmatically.design ideas
Or, in
pydantic
-ese, which generally makes a muck of human-readable schema:alternatives
#/properties/schema_version
field.json
files (see below)follow-on
$schema
to#/required
(e.g. by removing the| None
) would further strengthen this critical piece of metadatarequired
fields without a period where they are optional first is fairly drasticreferences
pixi.toml
schemanull
values (which can't be represented in that serialization)...