feat: aggregate defaults and values

- Output merged defaults and values
- Add "check" command
This commit is contained in:
2022-09-27 22:20:44 +02:00
committed by Bornholm
parent 53b2bba28b
commit f4b3d8f532
26 changed files with 3229 additions and 65 deletions

View File

@ -1,7 +1,7 @@
{{ define "form_input_array" }}
{{ $root := . }}
{{ $fullProperty := getFullProperty .Parent .Property }}
{{ $values := getValue .Defaults .Values $fullProperty }}
{{ $values := getValue .Values $fullProperty }}
<table width="100%">
<tbody>
{{ range $index, $value := $values }}

View File

@ -1,6 +1,6 @@
{{define "form_input_boolean"}}
{{ $fullProperty := getFullProperty .Parent .Property }}
{{ $checked := getValue .Defaults .Values $fullProperty }}
{{ $checked := getValue .Values $fullProperty }}
<label for="yes:{{ $fullProperty }}" class="inline-flex items-center mt-3">
<input type="radio"
class="h-5 w-5 text-gray-600"

View File

@ -1,6 +1,6 @@
{{define "form_input_number"}}
{{ $fullProperty := getFullProperty .Parent .Property }}
{{ $value := getValue .Defaults .Values $fullProperty }}
{{ $value := getValue .Values $fullProperty }}
<input type="number"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5"
name="num:{{ $fullProperty }}"

View File

@ -1,6 +1,6 @@
{{define "form_input_string"}}
{{ $fullProperty := getFullProperty .Parent .Property }}
{{ $value := getValue .Defaults .Values $fullProperty }}
{{ $value := getValue .Values $fullProperty }}
{{/* <input type="text"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5"
name="{{ $fullProperty }}"

View File

@ -162,11 +162,7 @@ func customHelpers(tpl *template.Template) template.FuncMap {
return fullProperty
},
"getValue": func(defaults, values interface{}, path string) (interface{}, error) {
if defaults == nil {
defaults = make(map[string]interface{})
}
"getValue": func(values interface{}, path string) (interface{}, error) {
if values == nil {
values = make(map[string]interface{})
}
@ -178,13 +174,6 @@ func customHelpers(tpl *template.Template) template.FuncMap {
return nil, errors.WithStack(err)
}
if errors.Is(err, jsonpointer.ErrNotFound) {
val, err = pointer.Get(defaults)
if err != nil && !errors.Is(err, jsonpointer.ErrNotFound) {
return nil, errors.WithStack(err)
}
}
return val, nil
},
"getItemSchema": func(arraySchema *jsonschema.Schema) (*jsonschema.Schema, error) {