| 180 | } |
| 181 | |
| 182 | func Vars(s *jsonschema.Schema) { |
| 183 | if s.Type == "" { |
| 184 | return |
| 185 | } |
| 186 | |
| 187 | if s.Type == "string" { |
| 188 | return |
| 189 | } |
| 190 | |
| 191 | if s.Type == "object" { |
| 192 | return |
| 193 | } |
| 194 | |
| 195 | if s.Type == "array" { |
| 196 | return |
| 197 | } |
| 198 | |
| 199 | if len(s.AnyOf) > 0 { |
| 200 | s.AnyOf = append(s.AnyOf, &jsonschema.Schema{ |
| 201 | Type: "string", |
| 202 | Pattern: varspkg.VarMatchRegex.String(), |
| 203 | }) |
| 204 | } else { |
| 205 | if len(s.OneOf) == 0 { |
| 206 | // Preserve original type |
| 207 | s.OneOf = append(s.OneOf, &jsonschema.Schema{ |
| 208 | Type: s.Type, |
| 209 | Items: s.Items, |
| 210 | PatternProperties: s.PatternProperties, |
| 211 | }) |
| 212 | } |
| 213 | s.OneOf = append(s.OneOf, &jsonschema.Schema{ |
| 214 | Type: "string", |
| 215 | Pattern: varspkg.VarMatchRegex.String(), |
| 216 | }) |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | func CleanUp(s *jsonschema.Schema) { |
| 221 | if len(s.OneOf) > 0 || len(s.AnyOf) > 0 { |