diff --git a/DependencyInjection/NelmioApiDocExtension.php b/DependencyInjection/NelmioApiDocExtension.php
index e252b94..b985797 100644
--- a/DependencyInjection/NelmioApiDocExtension.php
+++ b/DependencyInjection/NelmioApiDocExtension.php
@@ -15,9 +15,13 @@ use FOS\RestBundle\Controller\Annotations\ParamInterface;
use phpDocumentor\Reflection\DocBlockFactory;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Definition;
+use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
+use Symfony\Component\Routing\RouteCollection;
+use Nelmio\ApiDocBundle\Routing\FilteredRouteCollectionBuilder;
final class NelmioApiDocExtension extends Extension implements PrependExtensionInterface
{
@@ -40,8 +44,22 @@ final class NelmioApiDocExtension extends Extension implements PrependExtensionI
$loader->load('services.xml');
// Filter routes
- $routeCollectionBuilder = $container->getDefinition('nelmio_api_doc.filtered_route_collection_builder');
- $routeCollectionBuilder->replaceArgument(0, $config['routes']['path_patterns']);
+ $routesDefinition = (new Definition(RouteCollection::class))
+ ->setFactory([new Reference('router'), 'getRouteCollection']);
+
+ if (0 === count($config['routes']['path_patterns'])) {
+ $container->setDefinition('nelmio_api_doc.routes', $routesDefinition)
+ ->setPublic(false);
+ } else {
+ $container->register('nelmio_api_doc.routes', RouteCollection::class)
+ ->setPublic(false)
+ ->setFactory([
+ (new Definition(FilteredRouteCollectionBuilder::class))
+ ->addArgument($config['routes']['path_patterns']),
+ 'filter']
+ )
+ ->addArgument($routesDefinition);
+ }
// Import services needed for each library
$loader->load('swagger_php.xml');
diff --git a/Resources/config/services.xml b/Resources/config/services.xml
index fe310ae..7dbd707 100644
--- a/Resources/config/services.xml
+++ b/Resources/config/services.xml
@@ -21,19 +21,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -42,7 +29,7 @@
-
+
diff --git a/Resources/config/swagger_php.xml b/Resources/config/swagger_php.xml
index bb4855e..b2e249c 100644
--- a/Resources/config/swagger_php.xml
+++ b/Resources/config/swagger_php.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/Resources/public/init-swagger-ui.js b/Resources/public/init-swagger-ui.js
index b4362f7..1d73823 100644
--- a/Resources/public/init-swagger-ui.js
+++ b/Resources/public/init-swagger-ui.js
@@ -21,46 +21,5 @@ window.onload = () => {
layout: 'StandaloneLayout'
});
- if (data.oauth.enabled) {
- ui.initOAuth({
- clientId: data.oauth.clientId,
- clientSecret: data.oauth.clientSecret,
- realm: data.oauth.type,
- appName: data.spec.info.title,
- scopeSeparator: ' ',
- additionalQueryStringParams: {}
- });
- }
-
window.ui = ui;
-
- if (!data.operationId) return;
-
- const observer = new MutationObserver(function (mutations, self) {
- const op = document.getElementById(`operations,${data.method}-${data.path},${data.shortName}`);
- if (!op) return;
-
- self.disconnect();
-
- op.querySelector('.opblock-summary').click();
- op.querySelector('.try-out__btn').click();
-
- if (data.id) {
- const inputId = op.querySelector('.parameters input[placeholder="id"]');
- inputId.value = data.id;
- inputId.dispatchEvent(new Event('input', { bubbles: true }));
- }
-
- for (let input of op.querySelectorAll('.parameters input')) {
- if (input.placeholder in data.queryParameters) {
- input.value = data.queryParameters[input.placeholder];
- input.dispatchEvent(new Event('input', { bubbles: true }));
- }
- }
-
- op.querySelector('.execute').click();
- op.scrollIntoView();
- });
-
- observer.observe(document, {childList: true, subtree: true});
};