algenza / fake-json-generator
Fake Json Generator for mocking API
v1.1.0
2017-02-24 02:10 UTC
Requires
- fzaninotto/faker: ^1.6
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is auto-updated.
Last update: 2024-12-19 20:44:00 UTC
README
Installation
composer require algenza/fake-json-generator
How to use?
Make schema
{ "type": "object", "properties": { "users": { "type": "object", "minimum": 102, "maximum": 101, "properties": { "id": { "value": "faker.randomNumber" "unique": true, }, "name": { "value": "faker.name" }, "email": { "value": "faker.email" }, "hallo": { "value": "hallo" }, "phone": { "type": "array", "minimum": 1, "maximum": 1, "items": { "value": "faker.e164PhoneNumber" } } } }, "Companies": { "type": "object", "minimum": 20, "maximum": 20, "properties": { "id": { "definition" : "uniqueId" }, "name": { "value": "faker.company" "unique": true }, "suffix": { "value": "faker.companySuffix" }, "address": { "value": "faker.streetName" }, "type": { "value": "Type A" }, "phone": { "type": "array", "minimum": 1, "maximum": 1, "items": { "value": "faker.e164PhoneNumber" } } } } }, "required": ["users","companies"], "definitions" : { "uniqueId" : { "value": "faker.randomNumber", "unique": true } } }
then generate
use Algenza\Fjg\Generator; $schemaPath = 'path_to_schema'; $jsonPath = 'path_to_generated_json'; $generator = new Generator($schemaPath, $jsonPath); $generator->run();
Lisence
MIT