Add `$id`, `title`, and `description` top level keys
RothAndrew opened this issue · 3 comments
AFAIK the tool doesn't currently offer the ability to set $id
, title
, and description
entries to the top level object. This results in undefined
entries when using tools such as Adobe's jsonschema2md tool.
Example:
If $id
, title
, and description
fields were able to be added, I could get something like:
Proposed Solution:
What about something like looking for a @schemaroot
comment?:
# @schemaroot $id: values.yaml; title: values.yaml; description: Helm chart values
My workaround for this was to do my own pre-commit hook, adding a jq
command at the end.
In .pre-commit-config.yaml:
- repo: local
hooks:
- id: helm-schema
name: helm-schema
entry: scripts/helm-schema.sh
language: script
files: chart/values.yaml
types: [yaml]
In scripts/helm-schema.sh:
#!/usr/bin/env sh
set -e
if ! helm plugin list | grep -q "schema"; then
echo "Error: Helm plugin 'schema' is not installed. Please install helm-values-schema-json plugin! https://github.com/losisin/helm-values-schema-json#install" >&2
exit 1
fi
helm schema -input chart/values.yaml -output chart/values.schema.json.tmp -draft 7 -indent 2
jq '. + {"$id": "values.yaml", "title": "values.yaml", "description": "Helm chart values."}' chart/values.schema.json.tmp > chart/values.schema.json
rm chart/values.schema.json.tmp
@RothAndrew adding $id
, title
and description
to the root object sounds like a good idea. I would prefer to do it with CLI flags and eventually add feature to read settings from config file. Would that work for you?
Sounds good!