Improvements to field generation (#137)

* Remove `no-embedded-types` flag

We don't use this.

* Use `fw-download.ubnt.com`

* Return firmware download URL from `latestUnifiVersion`

* Don't use version metadata
This commit is contained in:
Joshua Spence
2023-05-26 15:29:07 +10:00
committed by GitHub
parent 93d9584462
commit 97b562a6d2
6 changed files with 180 additions and 197 deletions

View File

@@ -17,11 +17,6 @@
{{- else }}
dst.{{ .FieldName }} = {{ .FieldType }}(aux.{{ .FieldName }})
{{- end }}{{- end }}{{- end }}
{{ define "field-embed" }}
{{ .FieldName }} {{ if .IsArray }}[]{{end}}{{ if not .Fields }}{{ .FieldType }}{{ else }}struct {
{{ range $fk, $fv := .Fields }}{{ if not $fv }}
{{ else }}{{- template "field-embed" $fv }}{{ end }}{{ end }}
}{{ end }} `json:"{{ .JSONName }}{{ if .OmitEmpty }},omitempty{{ end }}"` {{ if .FieldValidation }}// {{ .FieldValidation }}{{ end }} {{- end }}
// Code generated from ace.jar fields *.json files
// DO NOT EDIT.
@@ -40,14 +35,6 @@ var (
_ json.Marshaler
)
{{ if embedTypes -}}
{{- $k := .StructName -}}
{{- $v :=index .Types .StructName -}}
type {{ $k }} struct {
{{ range $fk, $fv := $v.Fields }}{{ if not $fv }}
{{ else }}{{- template "field-embed" $fv }}{{ end }}{{ end }}
}
{{- else -}}
{{ range $k, $v := .Types }}
type {{ $k }} struct {
{{ range $fk, $fv := $v.Fields }}{{ if not $fv }}
@@ -76,7 +63,6 @@ func (dst *{{ $k }}) UnmarshalJSON(b []byte) error {
return nil
}
{{ end }}
{{- end -}}
{{ if not .IsSetting }}
func (c *Client) list{{ .StructName }}(ctx context.Context, site string) ([]{{ .StructName }}, error) {