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;
|
|
|
|
|
2016-07-15 00:40:30 +02:00
|
|
|
use EXSyst\Bundle\ApiDocBundle\Describer\DescriberInterface;
|
2016-08-01 19:58:57 +02:00
|
|
|
use EXSyst\Component\Swagger\Swagger;
|
2016-06-30 23:30:37 +02:00
|
|
|
|
|
|
|
class ApiDocGenerator
|
|
|
|
{
|
2016-07-13 23:05:14 +02:00
|
|
|
private $swagger;
|
2016-07-15 00:40:30 +02:00
|
|
|
private $describers;
|
2016-06-30 23:30:37 +02:00
|
|
|
|
|
|
|
/**
|
2016-07-15 00:40:30 +02:00
|
|
|
* @param DescriberInterface[] $describers
|
2016-06-30 23:30:37 +02:00
|
|
|
*/
|
2016-07-15 00:40:30 +02:00
|
|
|
public function __construct(array $describers)
|
2016-06-30 23:30:37 +02:00
|
|
|
{
|
2016-07-15 00:40:30 +02:00
|
|
|
$this->describers = $describers;
|
2016-06-30 23:30:37 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 20:27:51 +02:00
|
|
|
public function extract(): Swagger
|
2016-06-30 23:30:37 +02:00
|
|
|
{
|
2016-07-13 23:05:14 +02:00
|
|
|
if (null !== $this->swagger) {
|
|
|
|
return $this->swagger;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->swagger = new Swagger();
|
2016-07-15 00:40:30 +02:00
|
|
|
foreach ($this->describers as $describer) {
|
|
|
|
$describer->describe($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
|
|
|
}
|
|
|
|
}
|