alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
288 stars 49 forks source link

Is there a schema available for the Alire Toml? #1755

Open Joebeazelman opened 2 months ago

Joebeazelman commented 2 months ago

I haven't been able to find a schema for Alire's Toml, which would make it a lot easier to work with. VSCode has the ability to suggest and autocomplete based on it.

Fabien-Chouteau commented 2 months ago

That would be useful indeed. What format does VSCode use for the schema?

Joebeazelman commented 2 months ago

There are two levels of TOML schemas: one for the configuration file format (JSON Schema, XML Schema), and another for the data represented in that format (JSON:API, WSDL). Unlike more established formats, the TOML standard specifies neither.

Since VSCode doesn't support TOML, its validation is left to third-party extensions. Even Better TOML, part of the Taplo tools and libraries, is the most popular and feature complete one, supporting not only validation, but also syntax coloring, and formatting.

Even Better TOML uses its own TOML data schema based on the JSON Schema draft 4 specification. Schemas can be published to the public catalog, JSON Schema Store. Documentation is quite sparse, but there's a few reference examples available on the schema store. To specify a schema for a TOML file, there are several methods, but the one involving the least configuration on the part of the client is by setting an Alire environment variable.

Fabien-Chouteau commented 2 months ago

Thanks @Joebeazelman,

This looks very interesting. The main question at this point is whether or not we can generate the schema from Alire code. Maintaining this by hand seems extremely error prone.

mosteo commented 1 month ago

We generate a subset of the manifest programmatically, so maybe the schema generation could be hooked there.

Joebeazelman commented 1 month ago

Interesting. Do you think it's more advantageous for clients to source the schema directly from Alire or from the public JSON Schema Store? VSCode and Even Better TOML clients have the flexibility to source either, but others may not be as flexible. This would entail resubmition to the Schema Store whenever Alire is updated.