File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -375,6 +375,33 @@ schema = {
375
375
errors = JSON ::Validator .fully_validate(schema, {" a" => " 23" })
376
376
```
377
377
378
+ Validating a JSON Schema
379
+ ------------------------
380
+
381
+ To validate that a JSON Schema conforms to the JSON Schema standard,
382
+ you need to validate your schema against the metaschema for the appropriate
383
+ JSON Schema Draft. All of the normal validation methods can be used
384
+ for this. First retrieve the appropriate metaschema from the internal
385
+ cache (using ` JSON::Validator.validator_for_name() ` or
386
+ ` JSON::Validator.validator_for_uri() ` ) and then simply validate your
387
+ schema against it.
388
+
389
+
390
+ ``` ruby
391
+ require " json-schema"
392
+
393
+ schema = {
394
+ " type" => " object" ,
395
+ " properties" => {
396
+ " a" => {" type" => " integer" }
397
+ }
398
+ }
399
+
400
+ metaschema = JSON ::Validator .validator_for_name(" draft4" ).metaschema
401
+ # => true
402
+ JSON ::Validator .validate(metaschema, schema)
403
+ ```
404
+
378
405
Controlling Remote Schema Reading
379
406
---------------------------------
380
407
You can’t perform that action at this time.
0 commit comments