| 144 | } |
| 145 | |
| 146 | func Expressions(s *jsonschema.Schema) { |
| 147 | if s.Type == "" && s.Ref == "" { |
| 148 | return |
| 149 | } |
| 150 | |
| 151 | if s.Type == "string" { |
| 152 | return |
| 153 | } |
| 154 | |
| 155 | if len(s.AnyOf) > 0 { |
| 156 | s.AnyOf = append(s.AnyOf, &jsonschema.Schema{ |
| 157 | Type: "string", |
| 158 | Pattern: expression.ExpressionMatchRegex.String(), |
| 159 | }) |
| 160 | } else { |
| 161 | if len(s.OneOf) == 0 { |
| 162 | // Preserve original type |
| 163 | if s.Ref != "" { |
| 164 | s.OneOf = append(s.OneOf, &jsonschema.Schema{ |
| 165 | Ref: s.Ref, |
| 166 | }) |
| 167 | } else { |
| 168 | s.OneOf = append(s.OneOf, &jsonschema.Schema{ |
| 169 | Type: s.Type, |
| 170 | Items: s.Items, |
| 171 | PatternProperties: s.PatternProperties, |
| 172 | }) |
| 173 | } |
| 174 | } |
| 175 | s.OneOf = append(s.OneOf, &jsonschema.Schema{ |
| 176 | Type: "string", |
| 177 | Pattern: expression.ExpressionMatchRegex.String(), |
| 178 | }) |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | func Vars(s *jsonschema.Schema) { |
| 183 | if s.Type == "" { |