2014-06-17 17:05:00 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Nelmio\ApiDocBundle\DependencyInjection;
|
|
|
|
|
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compiler pass that configures the SwaggerFormatter instance.
|
|
|
|
*
|
|
|
|
* @author Bez Hermoso <bez@activelamp.com>
|
|
|
|
*/
|
|
|
|
class SwaggerConfigCompilerPass implements CompilerPassInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* You can modify the container here before it is dumped to PHP code.
|
|
|
|
*
|
|
|
|
* @api
|
|
|
|
*/
|
2024-10-01 15:54:04 +03:00
|
|
|
public function process(ContainerBuilder $container): void
|
2014-06-17 17:05:00 -07:00
|
|
|
{
|
|
|
|
$formatter = $container->getDefinition('nelmio_api_doc.formatter.swagger_formatter');
|
|
|
|
|
2024-10-01 15:54:04 +03:00
|
|
|
$formatter->addMethodCall('setBasePath', [$container->getParameter('nelmio_api_doc.swagger.base_path')]);
|
|
|
|
$formatter->addMethodCall('setApiVersion', [$container->getParameter('nelmio_api_doc.swagger.api_version')]);
|
|
|
|
$formatter->addMethodCall('setSwaggerVersion', [$container->getParameter('nelmio_api_doc.swagger.swagger_version')]);
|
|
|
|
$formatter->addMethodCall('setInfo', [$container->getParameter('nelmio_api_doc.swagger.info')]);
|
2014-06-17 17:05:00 -07:00
|
|
|
|
2014-08-04 10:58:41 -07:00
|
|
|
$authentication = $container->getParameter('nelmio_api_doc.sandbox.authentication');
|
|
|
|
|
2024-10-01 15:54:04 +03:00
|
|
|
$formatter->setArguments([
|
2014-08-07 12:06:04 -07:00
|
|
|
$container->getParameter('nelmio_api_doc.swagger.model_naming_strategy'),
|
2024-10-01 15:54:04 +03:00
|
|
|
]);
|
2014-08-07 12:06:04 -07:00
|
|
|
|
2024-10-01 15:54:04 +03:00
|
|
|
if (null !== $authentication) {
|
|
|
|
$formatter->addMethodCall('setAuthenticationConfig', [$authentication]);
|
2014-08-04 10:58:41 -07:00
|
|
|
}
|
2014-06-17 17:05:00 -07:00
|
|
|
}
|
2015-03-06 11:19:08 +01:00
|
|
|
}
|