PHP code example of langsys / swagger-auto-generator
1. Go to this page and download the library: Download langsys/swagger-auto-generator 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/ */
declare(strict_types=1);
namespace App\DataObjects;
use Spatie\LaravelData\Data;
/** @typescript */
final class UserData extends Data
{
public function __construct(
public string $id,
public string $firstname,
public string $lastname,
public string $email,
public ?string $email_verified_at,
public string $password,
public ?string $remember_token,
public ?string $created_at,
public ?string $updated_at,
) {
}
}
'faker_attribute_mapper' => [
'address_1' => 'streetAddress',
'address_2' => 'buildingNumber',
'zip' => 'postcode',
'_at' => 'date',
'_url' => 'url',
'locale' => 'locale',
'phone' => 'phoneNumber',
'_id' => 'id'
],
//These are examples of custom functions that can be used in the data object, you can add more functions here, or remove them if you don't need them.
'custom_functions' => [
'id' => [\Langsys\SwaggerAutoGenerator\Functions\CustomFunctions::class,'id'],
'locale' => [\Langsys\SwaggerAutoGenerator\Functions\CustomFunctions::class,'locale'],
'date' => [\Langsys\SwaggerAutoGenerator\Functions\CustomFunctions::class,'date'],
],
namespace Langsys\SwaggerAutoGenerator\Functions;
use App\Models\Locale;
class CustomFunctions
{
public function locale(): string
{
$locales = Locale::all();
return $locales->get(random_int(1, $locales->count()))->code;
}
}