| 37 | } |
| 38 | |
| 39 | func (s *Schema) createMergeItems(other *Schema) mergeItems { |
| 40 | minInt := func(a, b *int) bool { return (a == nil && b != nil) || (a != nil && b != nil && *a > *b) } |
| 41 | maxInt := func(a, b *int) bool { return (a == nil && b != nil) || (a != nil && b != nil && *a < *b) } |
| 42 | minFloat64 := func(a, b *float64) bool { return (a == nil && b != nil) || (a != nil && b != nil && *a > *b) } |
| 43 | maxFloat64 := func(a, b *float64) bool { return (a == nil && b != nil) || (a != nil && b != nil && *a < *b) } |
| 44 | |
| 45 | return mergeItems{ |
| 46 | {&s.ID, other.ID, s.ID == ""}, |
| 47 | {&s.Type, other.Type, s.Type == ""}, |
| 48 | {&s.Ref, other.Ref, s.Ref == ""}, |
| 49 | {&s.Items, other.Items, s.Items == nil}, |
| 50 | {&s.DefaultValue, other.DefaultValue, s.DefaultValue == nil}, |
| 51 | {&s.Title, other.Title, s.Title == ""}, |
| 52 | {&s.Media, other.Media, s.Media == nil}, |
| 53 | {&s.ReadOnly, other.ReadOnly, !s.ReadOnly}, |
| 54 | {&s.PathStart, other.PathStart, s.PathStart == ""}, |
| 55 | {&s.Enum, other.Enum, s.Enum == nil}, |
| 56 | {&s.Format, other.Format, s.Format == ""}, |
| 57 | {&s.Pattern, other.Pattern, s.Pattern == ""}, |
| 58 | {&s.AdditionalProperties, other.AdditionalProperties, s.AdditionalProperties == nil}, |
| 59 | {&s.Minimum, other.Minimum, minFloat64(s.Minimum, other.Minimum)}, |
| 60 | {&s.Maximum, other.Maximum, maxFloat64(s.Maximum, other.Maximum)}, |
| 61 | {&s.MinLength, other.MinLength, minInt(s.MinLength, other.MinLength)}, |
| 62 | {&s.MaxLength, other.MaxLength, maxInt(s.MaxLength, other.MaxLength)}, |
| 63 | {&s.MinItems, other.MinItems, minInt(s.MinItems, other.MinItems)}, |
| 64 | {&s.MaxItems, other.MaxItems, maxInt(s.MaxItems, other.MaxItems)}, |
| 65 | } |
| 66 | } |