2012-04-12 20:34:19 +02:00
|
|
|
<?php
|
|
|
|
|
2012-04-13 11:03:05 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the NelmioApiDocBundle.
|
|
|
|
*
|
|
|
|
* (c) Nelmio <hello@nelm.io>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2012-04-13 10:05:32 +02:00
|
|
|
namespace Nelmio\ApiDocBundle\DependencyInjection;
|
2012-04-12 20:34:19 +02:00
|
|
|
|
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
|
|
|
|
|
|
|
class Configuration implements ConfigurationInterface
|
|
|
|
{
|
|
|
|
public function getConfigTreeBuilder()
|
|
|
|
{
|
|
|
|
$treeBuilder = new TreeBuilder();
|
|
|
|
$treeBuilder
|
|
|
|
->root('nelmio_api_doc')
|
|
|
|
->children()
|
|
|
|
->scalarNode('name')->defaultValue('API documentation')->end()
|
2013-04-08 11:44:43 +02:00
|
|
|
->arrayNode('motd')
|
|
|
|
->addDefaultsIfNotSet()
|
|
|
|
->children()
|
|
|
|
->scalarNode('template')->defaultValue('NelmioApiDocBundle::Components/motd.html.twig')->end()
|
|
|
|
->end()
|
|
|
|
->end()
|
2012-10-17 18:44:14 +04:00
|
|
|
->arrayNode('request_listener')
|
|
|
|
->beforeNormalization()
|
|
|
|
->ifTrue(function ($a) { return is_bool($a); })
|
|
|
|
->then(function ($a) { return array('enabled' => $a); })
|
|
|
|
->end()
|
|
|
|
->addDefaultsIfNotSet()
|
|
|
|
->children()
|
|
|
|
->booleanNode('enabled')->defaultTrue()->end()
|
|
|
|
->scalarNode('parameter')->defaultValue('_doc')->end()
|
|
|
|
->end()
|
|
|
|
->end()
|
2012-07-18 13:18:26 +02:00
|
|
|
->arrayNode('sandbox')
|
|
|
|
->addDefaultsIfNotSet()
|
|
|
|
->children()
|
|
|
|
->scalarNode('enabled')->defaultTrue()->end()
|
2013-03-01 21:24:54 +01:00
|
|
|
->scalarNode('endpoint')->defaultNull()->end()
|
2012-12-11 17:59:03 -08:00
|
|
|
->scalarNode('accept_type')->defaultValue('')->end()
|
2013-06-04 15:30:07 -07:00
|
|
|
->enumNode('body_format')
|
|
|
|
->values(array('form', 'json'))
|
|
|
|
->defaultValue('form')
|
|
|
|
->end()
|
2012-10-17 15:27:20 +04:00
|
|
|
->arrayNode('request_format')
|
|
|
|
->addDefaultsIfNotSet()
|
|
|
|
->children()
|
|
|
|
->enumNode('method')
|
|
|
|
->values(array('format_param', 'accept_header'))
|
|
|
|
->defaultValue('format_param')
|
|
|
|
->end()
|
|
|
|
->enumNode('default_format')
|
|
|
|
->values(array('json', 'xml'))
|
|
|
|
->defaultValue('json')
|
|
|
|
->end()
|
|
|
|
->end()
|
2012-10-16 23:41:16 +04:00
|
|
|
->end()
|
2012-08-10 13:55:35 +02:00
|
|
|
->arrayNode('authentication')
|
|
|
|
->children()
|
|
|
|
->scalarNode('name')->isRequired()->end()
|
2012-10-17 15:15:35 +04:00
|
|
|
->scalarNode('delivery')
|
2012-08-10 13:55:35 +02:00
|
|
|
->isRequired()
|
2012-10-17 15:15:35 +04:00
|
|
|
->validate()
|
|
|
|
// header|query|request, but only query is implemented for now
|
2013-07-19 10:05:57 +02:00
|
|
|
->ifNotInArray(array('query', 'http_basic', 'header'))
|
2012-10-17 15:15:35 +04:00
|
|
|
->thenInvalid("Unknown authentication delivery type '%s'.")
|
|
|
|
->end()
|
2012-08-10 13:55:35 +02:00
|
|
|
->end()
|
2013-04-12 08:49:38 +03:00
|
|
|
->booleanNode('custom_endpoint')->defaultFalse()->end()
|
2012-08-10 13:55:35 +02:00
|
|
|
->end()
|
|
|
|
->end()
|
2012-07-18 13:18:26 +02:00
|
|
|
->end()
|
|
|
|
->end()
|
2012-05-24 01:22:45 +02:00
|
|
|
->end();
|
2012-04-12 20:34:19 +02:00
|
|
|
|
|
|
|
return $treeBuilder;
|
|
|
|
}
|
|
|
|
}
|