PHP code example of ybelenko / openapi-data-mocker
1. Go to this page and download the library: Download ybelenko/openapi-data-mocker library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ybelenko / openapi-data-mocker example snippets
use OpenAPIServer\Mock\OpenApiDataMocker as Mocker;
$mocker = new Mocker();
// set model classes namespace for $ref handling
// current example doesn't use $refs in schemas, however
$mocker->setModelsNamespace('JohnDoesPackage\\Model\\');
// class InvoiceTest contains schema mentioned previously
// it returns that schema with getOpenApiSchema() method declared in OpenAPIServer\Mock\BaseModel parent class
$schema = \OpenAPIServer\Mock\Model\InvoiceTest::getOpenApiSchema();
$data = $mocker->mockSchemaObject($schema);
echo json_encode($data, \JSON_PRETTY_PRINT);