2016-06-30 23:30:37 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the ApiDocBundle package.
|
|
|
|
*
|
|
|
|
* (c) EXSyst
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace EXSyst\Bundle\ApiDocBundle;
|
|
|
|
|
|
|
|
use EXSyst\Bundle\ApiDocBundle\Extractor\ExtractorInterface;
|
|
|
|
use gossi\swagger\Swagger;
|
|
|
|
|
|
|
|
class ApiDocGenerator
|
|
|
|
{
|
2016-07-13 23:05:14 +02:00
|
|
|
private $swagger;
|
2016-06-30 23:30:37 +02:00
|
|
|
private $extractors;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param ExtractorInterface[] $extractors
|
|
|
|
*/
|
|
|
|
public function __construct(array $extractors)
|
|
|
|
{
|
|
|
|
$this->extractors = $extractors;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Swagger
|
|
|
|
*/
|
|
|
|
public function extract()
|
|
|
|
{
|
2016-07-13 23:05:14 +02:00
|
|
|
if (null !== $this->swagger) {
|
|
|
|
return $this->swagger;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->swagger = new Swagger();
|
2016-06-30 23:30:37 +02:00
|
|
|
foreach ($this->extractors as $extractor) {
|
2016-07-13 23:05:14 +02:00
|
|
|
$extractor->extractIn($this->swagger);
|
2016-06-30 23:30:37 +02:00
|
|
|
}
|
|
|
|
|
2016-07-13 23:05:14 +02:00
|
|
|
return $this->swagger;
|
2016-06-30 23:30:37 +02:00
|
|
|
}
|
|
|
|
}
|