PHP code example of sonrac / swagger-php-openapi

1. Go to this page and download the library: Download sonrac/swagger-php-openapi 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/ */

    

sonrac / swagger-php-openapi example snippets


/**
 * @OAS\Info(title="My First API", version="0.1")
 */

/**
 * @OAS\Get(
 *     path="/api/resource.json",
 *     @OAS\Response(response="200", description="An example resource")
 * )
 */


api = \Swagger\scan('/path/to/project');
header('Content-Type: application/json');
echo $openapi;



use Swagger\Serializer;

$serializer = new Serializer();
$openapi = $serializer->deserialize($jsonString, 'Swagger\Annotations\OpenApi');
echo $openapi;
sh
composer global