Defines a basic Cue schema from our ongoing discussion, and generates the corresponding JSON schema.
Generates a JSON schema from a Cue schema and validates reference.yaml.
yj -yt < reference.yaml > reference.toml
# Then manually remove empty properties
See the generated defaults
To generate them:
# Generate default values in Yaml
echo '#yaml-language-server: $schema=./schema.json' > generated/defaults.yaml
cue eval schema.cue -e '#Config' --out yaml >> generated/defaults.yaml
# Generate default values in Toml
cue eval schema.cue -e '#Config' --out json | yj -jt > generated/defaults.toml
# Then manually remove empty properties
See the generated JSON Schema
To generate it:
zx --install convert.mjs
- JSON Schema limitations
- additional properties seem to be enabled (could be solved)
- "flex" struct definition is not supported (see
#Global.environment
). The problem is in the cue to OpenAPI export
- Do we want optional fields or required fields with defaults?