handle omitted is true bools

This commit is contained in:
Paul Tyng
2022-10-19 20:31:28 -04:00
parent 84afde7dce
commit 887fae8168
4 changed files with 39 additions and 19 deletions

View File

@@ -108,6 +108,7 @@ type FieldInfo struct {
IsArray bool
Fields map[string]*FieldInfo
CustomUnmarshalType string
CustomUnmarshalFunc string
}
func NewResource(structName string, resourcePath string) *Resource {
@@ -346,6 +347,17 @@ func main() {
f.OmitEmpty = true
return nil
}
case "Network":
resource.FieldProcessor = func(name string, f *FieldInfo) error {
switch name {
case "InternetAccessEnabled", "IntraNetworkAccessEnabled":
if f.FieldType == "bool" {
f.CustomUnmarshalType = "*bool"
f.CustomUnmarshalFunc = "emptyBoolToTrue"
}
}
return nil
}
case "SettingGlobalAp":
resource.FieldProcessor = func(name string, f *FieldInfo) error {
if strings.HasPrefix(name, "6E") {