findDefaults identifies struct fields with "default" tags and attempts to resolve their values using the provided registry.
(registry Registry, t reflect.Type)
| 280 | // findDefaults identifies struct fields with "default" tags and attempts to resolve |
| 281 | // their values using the provided registry. |
| 282 | func findDefaults(registry Registry, t reflect.Type) *findResult[any] { |
| 283 | return findInType(t, nil, func(sf reflect.StructField, i []int) any { |
| 284 | if d := sf.Tag.Get("default"); d != "" { |
| 285 | if sf.Type.Kind() == reflect.Pointer && sf.Type.Elem().Kind() == reflect.Struct { |
| 286 | panic("pointers to structs cannot have default values") |
| 287 | } |
| 288 | s := registry.Schema(sf.Type, true, "") |
| 289 | return convertType(sf.Type.Name(), sf.Type, jsonTagValue(registry, sf.Name, s, d)) |
| 290 | } |
| 291 | return nil |
| 292 | }, true) |
| 293 | } |
| 294 | |
| 295 | type headerInfo struct { |
| 296 | Field reflect.StructField |
no test coverage detected
searching dependent graphs…