mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
Add a config option to configure the base of the documentation
This commit is contained in:
parent
fcf0b104c0
commit
0f2cb3fde2
@ -22,6 +22,11 @@ final class Configuration implements ConfigurationInterface
|
|||||||
$treeBuilder
|
$treeBuilder
|
||||||
->root('nelmio_api_doc')
|
->root('nelmio_api_doc')
|
||||||
->children()
|
->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()
|
->scalarNode('source_folder')->defaultValue('%kernel.root_dir%/../src')->end()
|
||||||
->arrayNode('routes')
|
->arrayNode('routes')
|
||||||
->info('Filter the routes that are documented')
|
->info('Filter the routes that are documented')
|
||||||
|
@ -54,5 +54,8 @@ final class NelmioApiDocExtension extends Extension
|
|||||||
if (isset($bundles['ApiPlatformBundle']) && class_exists('ApiPlatform\Core\Documentation\Documentation')) {
|
if (isset($bundles['ApiPlatformBundle']) && class_exists('ApiPlatform\Core\Documentation\Documentation')) {
|
||||||
$loader->load('api_platform.xml');
|
$loader->load('api_platform.xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Import the base configuration
|
||||||
|
$container->getDefinition('nelmio_api_doc.describers.config')->replaceArgument(0, $config['documentation']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,13 @@
|
|||||||
<argument type="service" id="controller_name_converter" />
|
<argument type="service" id="controller_name_converter" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- Extractors -->
|
<!-- Describers -->
|
||||||
|
<service id="nelmio_api_doc.describers.config" class="Nelmio\ApiDocBundle\Describer\ExternalDocDescriber" public="false">
|
||||||
|
<argument type="collection" />
|
||||||
|
|
||||||
|
<tag name="nelmio_api_doc.describer" priority="1000" />
|
||||||
|
</service>
|
||||||
|
|
||||||
<service id="nelmio_api_doc.describers.route.filtered_route_collection_builder" class="Nelmio\ApiDocBundle\Routing\FilteredRouteCollectionBuilder" public="false">
|
<service id="nelmio_api_doc.describers.route.filtered_route_collection_builder" class="Nelmio\ApiDocBundle\Routing\FilteredRouteCollectionBuilder" public="false">
|
||||||
<argument type="collection" /> <!-- Path patterns -->
|
<argument type="collection" /> <!-- Path patterns -->
|
||||||
</service>
|
</service>
|
||||||
|
@ -17,6 +17,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||||||
|
|
||||||
class FunctionalTest extends WebTestCase
|
class FunctionalTest extends WebTestCase
|
||||||
{
|
{
|
||||||
|
public function testConfiguredDocumentation()
|
||||||
|
{
|
||||||
|
$this->assertEquals('My Test App', $this->getSwaggerDefinition()->getInfo()->getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
public function testUndocumentedAction()
|
public function testUndocumentedAction()
|
||||||
{
|
{
|
||||||
$paths = $this->getSwaggerDefinition()->getPaths();
|
$paths = $this->getSwaggerDefinition()->getPaths();
|
||||||
|
@ -62,6 +62,11 @@ class TestKernel extends Kernel
|
|||||||
|
|
||||||
// Filter routes
|
// Filter routes
|
||||||
$c->loadFromExtension('nelmio_api_doc', [
|
$c->loadFromExtension('nelmio_api_doc', [
|
||||||
|
'documentation' => [
|
||||||
|
'info' => [
|
||||||
|
'title' => 'My Test App',
|
||||||
|
],
|
||||||
|
],
|
||||||
'source_folder' => '%kernel.root_dir%',
|
'source_folder' => '%kernel.root_dir%',
|
||||||
'routes' => [
|
'routes' => [
|
||||||
'path_patterns' => ['^/api(?!/admin)'],
|
'path_patterns' => ['^/api(?!/admin)'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user