(path string, schema map[string]json.RawMessage)
| 273 | } |
| 274 | |
| 275 | func validateJSONSchemaDocument(path string, schema map[string]json.RawMessage) error { |
| 276 | if _, err := schemaTypes(schema["type"]); err != nil { |
| 277 | return fmt.Errorf("%s.type: %w", path, err) |
| 278 | } |
| 279 | |
| 280 | properties, err := schemaProperties(schema["properties"]) |
| 281 | if err != nil { |
| 282 | return fmt.Errorf("%s.properties: %w", path, err) |
| 283 | } |
| 284 | for key, childSchema := range properties { |
| 285 | if err := validateJSONSchemaDocument(path+".properties."+key, childSchema); err != nil { |
| 286 | return err |
| 287 | } |
| 288 | } |
| 289 | if _, _, err := schemaNonNegativeInteger(schema["minLength"]); err != nil { |
| 290 | return fmt.Errorf("%s.minLength: %w", path, err) |
| 291 | } |
| 292 | if _, _, err := schemaNonNegativeInteger(schema["minItems"]); err != nil { |
| 293 | return fmt.Errorf("%s.minItems: %w", path, err) |
| 294 | } |
| 295 | items, ok, err := schemaNode(schema["items"]) |
| 296 | if err != nil { |
| 297 | return fmt.Errorf("%s.items: %w", path, err) |
| 298 | } |
| 299 | if ok { |
| 300 | if err := validateJSONSchemaDocument(path+".items", items); err != nil { |
| 301 | return err |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | if err := validateJSONSchemaDocumentArray(path+".allOf", schema["allOf"]); err != nil { |
| 306 | return err |
| 307 | } |
| 308 | if err := validateJSONSchemaDocumentArray(path+".anyOf", schema["anyOf"]); err != nil { |
| 309 | return err |
| 310 | } |
| 311 | if err := validateJSONSchemaDocumentArray(path+".oneOf", schema["oneOf"]); err != nil { |
| 312 | return err |
| 313 | } |
| 314 | |
| 315 | node, ok, err := schemaNode(schema["not"]) |
| 316 | if err != nil { |
| 317 | return fmt.Errorf("%s.not: %w", path, err) |
| 318 | } |
| 319 | if ok { |
| 320 | if err := validateJSONSchemaDocument(path+".not", node); err != nil { |
| 321 | return err |
| 322 | } |
| 323 | } |
| 324 | return nil |
| 325 | } |
| 326 | |
| 327 | func validateJSONSchemaDocumentArray(path string, raw json.RawMessage) error { |
| 328 | nodes, err := schemaNodeArray(raw) |
no test coverage detected