dev-master
9999999-devGenerates JSON values from JSON Schema definitions for use as seed data, sample API responses, etc.
MIT
The Requires
The Development Requires
Wallogit.com
2017 © Pedro Peláez
Generates JSON values from JSON Schema definitions for use as seed data, sample API responses, etc.
This package generates JSON objects from JSON Schema definitions and fills them with random fake data. This is useful for creating sample seed data that must be in a specific structure, e.g. useful for API responses., (*2)
The functionality is similar to the json-schema-faker NodeJs package., (*3)
The recommended way to install this code is via Composer, (*4)
<?php require 'vendor/autoload.php';
For command line usage, move into the jenerator/ directory and call its command., (*5)
php jenerator example:show path/to/schema.json
The JSON Schema spec defines some formats that all compliant validators should respect. Jenerator will produce appropriately formatted mock data for each of these standard formats, (*6)
The following formats are custom and are not defined by the official JSON Schema spec. They exist solely to facilitate the generation of realistic mock data. Compliant validators should ignore these custom formats and any other custom keywords they may reference. Using a custom format is useful way to have this library generate example data of that format, but it is recommended that you include other other validation keywords that will ensure that any example data will properly validate. For example, you may use a schema such as this to indicate a year:, (*7)
{
"type": "string",
"format": "year"
}, (*8)
But you should include some other keywords that other validators will respect, e.g., (*9)
{
"type": "string",
"format": "year",
"pattern": "\d{4}"
}, (*10)
// TODO: // iban // return (new Payment(Factory::create(getLocale())))->iban($countryCode); // });, (*11)
The jenerator does not support the "not" keyword. The value generator will generate a value, but it does not
attempt to validate the result against any schema defined in the the not keyword; it does not attempt to
re-generate a value if the generated value validates against the not schema., (*12)
Unreliable support for the "oneOf" keyword. The value generator will pick one of the listed schemas, but it does not validate the generated value against the other schemas and re-generate, (*13)
No support for dependencies keyword, (*14)
**arrayUnique may remove items from an array that may cause the array size to fall below the minItems requirement., (*15)
Generates JSON values from JSON Schema definitions for use as seed data, sample API responses, etc.
MIT