emanueleminotto/json-schema-faker

Faker provider for JSON Schema

1.0.0 2019-07-05 19:13 UTC

This package is auto-updated.

Last update: 2024-11-29 05:21:19 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Utility based on fzaninotto/Faker to generate fake JSON starting from a JSON Schema.

Structure

If any of the following are applicable to your project, then the directory structure should follow industry best practices by being named the following.

bin/        
config/
src/
tests/
vendor/

Install

Via Composer

$ composer require emanueleminotto/json-schema-faker

Usage

$faker = Faker\Factory::create();
$faker->addProvider(new EmanueleMinotto\JsonSchemaFaker\JsonSchemaProvider());

$schema = '{
  "type": "array",
  "items": [
    {"type": "integer"},
    {"type": "string"}
  ]
}';
$data = $faker->jsonSchemaContent($schema);
// $data = $faker->jsonSchema(json_decode($schema, true));

var_dump($data);
/*
array(2) {
  [0]=>
  int(2336562738116576768)
  [1]=>
  string(62) "Officiis qui officiis quasi. Sed et dolorem omnis repellendus."
}
*/

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email minottoemanuele@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.