PHP code example of woohoolabs / spec-generator

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

    

woohoolabs / spec-generator example snippets


use Doctrine\Common\Cache\MemcachedCache;
use WoohooLabs\SpecGenerator\Swagger2\SwaggerSpec;
use WoohooLabs\SpecGenerator\Swagger2\Info\Contact;
use WoohooLabs\SpecGenerator\Swagger2\Info\MitLicense;

$memcached = new \Memcached();
$memcached->addServer("localhost", 11211);
$cache = new MemcachedCache();
$cache->setMemcached($memcached);

SwaggerSpec::getSpecification(
    function(SwaggerSpec $swagger) {
        $info= Info::create()
            ->setTitle("API Title")
            ->setVersion("1.0.0")
            ->setDescription("API Description")
            ->setContact(new Contact("Sam Support", "123-456-789", "[email protected]"))
            ->setLicense(new MitLicense())
        ;
    
        return $swagger
            ->setInfo($info)
            ->setBasePath("/")
            ->setConsumes(["application/json"])
            ->setSchemes(["http"])
            ->setProduces(["application/vnd.hal+json"])
            ->generate();
    },
    $cache     
);