JSON Schema for benthos.yaml
I'm new to benthos, and definitely impressed with the ease of use of the tool!
One thing that would be helpful while creating a YAML config file for benthos is some kind of JSON schema document to provide some level of autocomplete within my yaml file, similar to the GitHub Workflow schema. Does such a schema file exist? I'm hoping that since benthos provides error messages when an invalid schema is provided a document exists, and figured I would check before I go diving into building one out.
Thanks in advance for any help on this!
Hey @willwolfram18, it's actually almost possible to do this but it's not exposed yet as I'm not 100% sure what to do with the result in order to make it useful. The implementation is here: https://github.com/Jeffail/benthos/blob/master/internal/docs/json_schema.go. I think ideally we'd generate a general schema for the overall config format and then a list of definitions for each component type (and each implementation of the component type). Not sure if using definitions makes things easier or more complex.
There's a similar issue for doing similar things with CUE: https://github.com/Jeffail/benthos/issues/920. I've held off on both for now as ideally I want to do something useful with the output, a plugin for VSCode or something like that would definitely fit the bill.
Thanks for the quick response, @Jeffail !
So if I'm understanding your explanation correctly, you're saying that benthos basically operates on a code-first schema that is materialized at runtime, and used for linting at that time, but there is no static schema.json document as it were. Does that sound right?
If that's so, I definitely see the value in something like a VSCode extension that can provide some linting and autocomplete while editing, since defining a separate schema file would create some annoying—and possibly error prone—duplication.
Yeah it's all baked into the process, it means we can generate any format we like (and potentially set up a language server at some point). It's not documented but you can actually spit out a JSON document containing the config spec and every config field for each component type with benthos list --format json-full, it's huge though so maybe pipe it to a file before reading it.
Having it exist within the process also means we can present specs for custom plugins and templates that might not exist in the official benthos distribution.
This would be really neat +1