PHP code example of erasys / openapi-php

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

    

erasys / openapi-php example snippets




use erasys\OpenApi\Spec\v3 as OASv3;

$doc = new OASv3\Document(
    new OASv3\Info('My API', '1.0.0', 'My API description'),
    [
        '/foo/bar' => new OASv3\PathItem(
            [
                'get' => new OASv3\Operation(
                    [
                        '200' => new OASv3\Response('Successful response.'),
                        'default' => new OASv3\Response('Default error response.'),
                    ]
                ),
            ]
        ),
    ]
);

$yaml = $doc->toYaml();
$json = $doc->toJson();
$arr  = $doc->toArray();
$obj  = $doc->toObject();

 bash
$ composer 
 bash
$ git clone https://github.com/erasys/openapi-php.git