(template any, dir string, allowNull bool)
| 121 | } |
| 122 | |
| 123 | func generateSchema(template any, dir string, allowNull bool) error { |
| 124 | settingsSchema := jsonschema.Reflect(template) |
| 125 | if allowNull { |
| 126 | allowNullValues(settingsSchema) |
| 127 | } |
| 128 | |
| 129 | jsonSettingsSchema, err := json.MarshalIndent(settingsSchema, "", " ") |
| 130 | if err != nil { |
| 131 | return fmt.Errorf("failed to parse local schema: %w", err) |
| 132 | } |
| 133 | written, err := utilfn.WriteFileIfDifferent(dir, jsonSettingsSchema) |
| 134 | if !written { |
| 135 | fmt.Fprintf(os.Stderr, "no changes to %s\n", dir) |
| 136 | } |
| 137 | if err != nil { |
| 138 | return fmt.Errorf("failed to write local schema: %w", err) |
| 139 | } |
| 140 | return nil |
| 141 | } |
| 142 | |
| 143 | func generateWidgetsSchema(dir string) error { |
| 144 | metaT := reflect.TypeOf(waveobj.MetaMapType(nil)) |
no test coverage detected