...
1
16
17 package schema
18
19
20
21 func (s *Structural) Unfold() *Structural {
22 if s == nil {
23 return nil
24 }
25
26 mapper := Visitor{
27 Structural: func(s *Structural) bool {
28 if !s.XIntOrString {
29 return false
30 }
31
32 skipAnyOf := isIntOrStringAnyOfPattern(s)
33 skipFirstAllOfAnyOf := isIntOrStringAllOfPattern(s)
34 if skipAnyOf || skipFirstAllOfAnyOf {
35 return false
36 }
37
38 if s.ValueValidation == nil {
39 s.ValueValidation = &ValueValidation{}
40 }
41 if s.ValueValidation.AnyOf == nil {
42 s.ValueValidation.AnyOf = []NestedValueValidation{
43 {ForbiddenGenerics: Generic{Type: "integer"}},
44 {ForbiddenGenerics: Generic{Type: "string"}},
45 }
46 } else {
47 s.ValueValidation.AllOf = append([]NestedValueValidation{
48 {
49 ValueValidation: ValueValidation{
50 AnyOf: []NestedValueValidation{
51 {ForbiddenGenerics: Generic{Type: "integer"}},
52 {ForbiddenGenerics: Generic{Type: "string"}},
53 },
54 },
55 },
56 }, s.ValueValidation.AllOf...)
57 }
58
59 return true
60 },
61 NestedValueValidation: nil,
62 }
63 mapper.Visit(s)
64
65 return s
66 }
67
View as plain text