Make source folder configurable

This commit is contained in:
Baptiste Lafontaine 2017-01-19 09:43:44 +01:00
parent 3a29c598cc
commit 92c108839c
3 changed files with 5 additions and 0 deletions

View File

@ -22,6 +22,7 @@ final class Configuration implements ConfigurationInterface
$treeBuilder
->root('nelmio_api_doc')
->children()
->scalarNode('source_folder')->defaultValue('%kernel.root_dir%/../src')->end()
->arrayNode('routes')
->info('Filter the routes that are documented')
->addDefaultsIfNotSet()

View File

@ -41,6 +41,9 @@ final class NelmioApiDocExtension extends Extension
}
if (class_exists(Swagger::class)) {
$loader->load('swagger_php.xml');
$swaggerPHPDescriber = $container->getDefinition('nelmio_api_doc.describers.swagger_php');
$swaggerPHPDescriber->replaceArgument(0, $config['source_folder']);
}
if (interface_exists(ParamInterface::class)) {
$loader->load('fos_rest.xml');

View File

@ -62,6 +62,7 @@ class TestKernel extends Kernel
// Filter routes
$c->loadFromExtension('nelmio_api_doc', [
'source_folder' => '%kernel.root_dir%',
'routes' => [
'path_patterns' => ['^/api(?!/admin)'],
],