A JSON-schema $ref faker
Inspired on json-schema-validator for JAVA, the --fakeroot
option, actually.
This fork also allows non-standard references via "id"
.
If you're validating some RAML (like me) then you should validate your JSON-schemas and examples also.
For this purpose I'm using ramlev which is using tv4, but you're encouraged to download any $ref
manually before validating.
Solution?
var tv4 = refaker = ; var data = /* ... */ schema = /* ... */ ; ;
That's it.
Options
-
schema (object|aray)
The JSON-schema to validate.
-
schemas (object|array)
Multiple JSON-schemas to validate at once.
This is an alias for the schema option.
-
fakeroot (string)
If provided, any matching
$ref
will be resolved under the specifieddirectory
. -
directory (string)
A local path containing the JSON-schemas.
If missing, will use
process.cwd()
instead. -
timeout (number)
Timeout when resolving remote schemas, default to 200ms.
Any $ref
found will be downloaded or faked locally.
Callback
The given callback will receive three arguments:
-
err (mixed)
Empty means success.
-
refs (object)
Hash of resolved
$ref
s. -
schemas (array)
Normalized schemas if success (same order as input).