mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Test .{_format} removal
This commit is contained in:
parent
da6527060f
commit
ab3dec1125
@ -13,18 +13,21 @@ namespace EXSyst\Bundle\ApiDocBundle;
|
|||||||
|
|
||||||
use EXSyst\Bundle\ApiDocBundle\Describer\DescriberInterface;
|
use EXSyst\Bundle\ApiDocBundle\Describer\DescriberInterface;
|
||||||
use EXSyst\Component\Swagger\Swagger;
|
use EXSyst\Component\Swagger\Swagger;
|
||||||
|
use Psr\Cache\CacheItemPoolInterface;
|
||||||
|
|
||||||
final class ApiDocGenerator
|
final class ApiDocGenerator
|
||||||
{
|
{
|
||||||
private $swagger;
|
private $swagger;
|
||||||
private $describers;
|
private $describers;
|
||||||
|
private $cacheItemPool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DescriberInterface[] $describers
|
* @param DescriberInterface[] $describers
|
||||||
*/
|
*/
|
||||||
public function __construct(array $describers)
|
public function __construct(array $describers, CacheItemPoolInterface $cacheItemPool = null)
|
||||||
{
|
{
|
||||||
$this->describers = $describers;
|
$this->describers = $describers;
|
||||||
|
$this->cacheItemPool = $cacheItemPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generate(): Swagger
|
public function generate(): Swagger
|
||||||
@ -33,11 +36,22 @@ final class ApiDocGenerator
|
|||||||
return $this->swagger;
|
return $this->swagger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->cacheItemPool) {
|
||||||
|
$item = $this->cacheItemPool->getItem('swagger_doc');
|
||||||
|
if ($item->isHit()) {
|
||||||
|
return $this->swagger = $item->get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->swagger = new Swagger();
|
$this->swagger = new Swagger();
|
||||||
foreach ($this->describers as $describer) {
|
foreach ($this->describers as $describer) {
|
||||||
$describer->describe($this->swagger);
|
$describer->describe($this->swagger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($item)) {
|
||||||
|
$this->cacheItemPool->save($item->set($this->swagger));
|
||||||
|
}
|
||||||
|
|
||||||
return $this->swagger;
|
return $this->swagger;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class ApiController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/fosrest", methods={"POST"})
|
* @Route("/fosrest.{_format}", methods={"POST"})
|
||||||
* @QueryParam(name="foo")
|
* @QueryParam(name="foo")
|
||||||
* @RequestParam(name="bar")
|
* @RequestParam(name="bar")
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user