algenza / fake-json-generator
用于模拟API的假JSON生成器
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-09-19 20:11:55 UTC
README
安装
composer require algenza/fake-json-generator
如何使用?
制作模式
{ "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 } } }
然后生成
use Algenza\Fjg\Generator; $schemaPath = 'path_to_schema'; $jsonPath = 'path_to_generated_json'; $generator = new Generator($schemaPath, $jsonPath); $generator->run();
许可证
MIT