mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +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\Component\Swagger\Swagger;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
|
||||
final class ApiDocGenerator
|
||||
{
|
||||
private $swagger;
|
||||
private $describers;
|
||||
private $cacheItemPool;
|
||||
|
||||
/**
|
||||
* @param DescriberInterface[] $describers
|
||||
*/
|
||||
public function __construct(array $describers)
|
||||
public function __construct(array $describers, CacheItemPoolInterface $cacheItemPool = null)
|
||||
{
|
||||
$this->describers = $describers;
|
||||
$this->cacheItemPool = $cacheItemPool;
|
||||
}
|
||||
|
||||
public function generate(): Swagger
|
||||
@ -33,11 +36,22 @@ final class ApiDocGenerator
|
||||
return $this->swagger;
|
||||
}
|
||||
|
||||
if ($this->cacheItemPool) {
|
||||
$item = $this->cacheItemPool->getItem('swagger_doc');
|
||||
if ($item->isHit()) {
|
||||
return $this->swagger = $item->get();
|
||||
}
|
||||
}
|
||||
|
||||
$this->swagger = new Swagger();
|
||||
foreach ($this->describers as $describer) {
|
||||
$describer->describe($this->swagger);
|
||||
}
|
||||
|
||||
if (isset($item)) {
|
||||
$this->cacheItemPool->save($item->set($this->swagger));
|
||||
}
|
||||
|
||||
return $this->swagger;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class ApiController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/fosrest", methods={"POST"})
|
||||
* @Route("/fosrest.{_format}", methods={"POST"})
|
||||
* @QueryParam(name="foo")
|
||||
* @RequestParam(name="bar")
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user