PHP code example of algirdasc / laravel-openapi-tools

1. Go to this page and download the library: Download algirdasc/laravel-openapi-tools 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/ */

    

algirdasc / laravel-openapi-tools example snippets




declare(strict_types=1);

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

/**
 * @phpstan-ignore openApiTools.missingJsonResourceSchemaAttribute
 */
class MyResource extends JsonResource
{
    public function toArray(mixed $request): array
    {
        return [
            'some_property' => $this->resource->some_property,
        ]);
    }
}

...
#[OA\Schema(
    schema: 'Resources.Books.BookResource',
    properties: [
        /** @phpstan-ignore openApiTools.booleanInJsonResourceMustStartWithIs */
        new OA\Property('truncated', type: 'boolean', example: true),
    ],
)]
class BookResource extends JsonResource
...