diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 2eb1441..e51593d 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -22,6 +22,11 @@ final class Configuration implements ConfigurationInterface $treeBuilder ->root('nelmio_api_doc') ->children() + ->arrayNode('documentation') + ->info('The documentation used as base') + ->example(['info' => ['title' => 'My App']]) + ->prototype('variable')->end() + ->end() ->scalarNode('source_folder')->defaultValue('%kernel.root_dir%/../src')->end() ->arrayNode('routes') ->info('Filter the routes that are documented') diff --git a/DependencyInjection/NelmioApiDocExtension.php b/DependencyInjection/NelmioApiDocExtension.php index d3059bb..e426192 100644 --- a/DependencyInjection/NelmioApiDocExtension.php +++ b/DependencyInjection/NelmioApiDocExtension.php @@ -54,5 +54,8 @@ final class NelmioApiDocExtension extends Extension if (isset($bundles['ApiPlatformBundle']) && class_exists('ApiPlatform\Core\Documentation\Documentation')) { $loader->load('api_platform.xml'); } + + // Import the base configuration + $container->getDefinition('nelmio_api_doc.describers.config')->replaceArgument(0, $config['documentation']); } } diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 14bc892..f11dad0 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -14,7 +14,13 @@ - + + + + + + + diff --git a/Tests/Functional/FunctionalTest.php b/Tests/Functional/FunctionalTest.php index 94cc167..69272e7 100644 --- a/Tests/Functional/FunctionalTest.php +++ b/Tests/Functional/FunctionalTest.php @@ -17,6 +17,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class FunctionalTest extends WebTestCase { + public function testConfiguredDocumentation() + { + $this->assertEquals('My Test App', $this->getSwaggerDefinition()->getInfo()->getTitle()); + } + public function testUndocumentedAction() { $paths = $this->getSwaggerDefinition()->getPaths(); diff --git a/Tests/Functional/TestKernel.php b/Tests/Functional/TestKernel.php index 4c93ec2..c9c9093 100644 --- a/Tests/Functional/TestKernel.php +++ b/Tests/Functional/TestKernel.php @@ -62,6 +62,11 @@ class TestKernel extends Kernel // Filter routes $c->loadFromExtension('nelmio_api_doc', [ + 'documentation' => [ + 'info' => [ + 'title' => 'My Test App', + ], + ], 'source_folder' => '%kernel.root_dir%', 'routes' => [ 'path_patterns' => ['^/api(?!/admin)'],