Add controller version to generated files
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
{{ 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
|
||||
// Controller Version {{ .ControllerVersion }}
|
||||
// DO NOT EDIT.
|
||||
|
||||
package unifi
|
||||
|
||||
@@ -92,10 +92,11 @@ var fileReps = []replacement{
|
||||
var embedTypes bool
|
||||
|
||||
type Resource struct {
|
||||
StructName string
|
||||
ResourcePath string
|
||||
Types map[string]*FieldInfo
|
||||
FieldProcessor func(name string, f *FieldInfo) error
|
||||
ControllerVersion string
|
||||
StructName string
|
||||
ResourcePath string
|
||||
Types map[string]*FieldInfo
|
||||
FieldProcessor func(name string, f *FieldInfo) error
|
||||
}
|
||||
|
||||
type FieldInfo struct {
|
||||
@@ -109,9 +110,11 @@ type FieldInfo struct {
|
||||
CustomUnmarshalType string
|
||||
}
|
||||
|
||||
func NewResource(structName string, resourcePath string) *Resource {
|
||||
func NewResource(version string, structName string, resourcePath string) *Resource {
|
||||
baseType := NewFieldInfo(structName, resourcePath, "struct", "", false, false, "")
|
||||
resource := &Resource{
|
||||
ControllerVersion: version,
|
||||
|
||||
StructName: structName,
|
||||
ResourcePath: resourcePath,
|
||||
Types: map[string]*FieldInfo{
|
||||
@@ -296,7 +299,7 @@ func main() {
|
||||
continue
|
||||
}
|
||||
|
||||
resource := NewResource(structName, urlPath)
|
||||
resource := NewResource(fmt.Sprintf("v%s", unifiVersion), structName, urlPath)
|
||||
|
||||
switch resource.StructName {
|
||||
case "Account":
|
||||
|
||||
@@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
assert "github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
|
||||
assert "github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestFieldInfoFromValidation(t *testing.T) {
|
||||
@@ -145,7 +146,7 @@ func TestResourceTypes(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("structural test", func(t *testing.T) {
|
||||
resource := NewResource("Struct", "path")
|
||||
resource := NewResource("v1.1", "Struct", "path")
|
||||
resource.FieldProcessor = expectation.FieldProcessor
|
||||
|
||||
err := resource.processJSON(([]byte)(testData))
|
||||
|
||||
Reference in New Issue
Block a user