Generates fake data which will validate against your Swagger 2.0 schema.
composer require mlambley/swagfaker:^1.0
Swagger 2.0 (aka Open API 2.0) defines the structure of your API, including end points and the structure of input and output data. See their website for more information.
Swagfaker allows you to generate fake data based upon your existing Swagger 2.0 specification. You can use it to generate data to be sent to your API during acceptance testing.
Let's say your Swagger schema looks like this:
{
"type": "object",
"required": [
"Name",
"DateOfBirth",
"Identifier",
"VisitCount"
],
"properties": {
"Name": {
"type": "string"
},
"DateOfBirth": {
"type": "string",
"format": "date"
},
"Identifier": {
"type": "string",
"pattern": "^[0-9]{3}-[0-9]{4}$"
},
"VisitCount": {
"type": "integer",
"minimum": 0
}
}
}
Then generate fake data using:
$values = (new \SwaggerFaker\Faker())->generate($schema);
Your values now might look like this:
object(stdClass) {
"Name" => "Quod."
"DateOfBirth" => "1971-08-20"
"Identifier" => "037-1259"
"VisitCount" => 1463093889
}
Log a github issue. Your assistance is appreciated.
Give some love to Leko for their JSON Schema Faker which this library was originally copied from.