mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Fix usage of configureRoutes in tests
This commit is contained in:
parent
2ade72d0aa
commit
e04521ebea
40
Tests/Functional/Resources/routes.yaml
Normal file
40
Tests/Functional/Resources/routes.yaml
Normal file
@ -0,0 +1,40 @@
|
||||
# Resources
|
||||
test:
|
||||
resource: ../Controller/TestController.php
|
||||
type: annotation
|
||||
|
||||
api:
|
||||
resource: ../Controller/ApiController.php
|
||||
type: annotation
|
||||
|
||||
class_api:
|
||||
resource: ../Controller/ClassApiController.php
|
||||
type: annotation
|
||||
|
||||
undocumented:
|
||||
resource: ../Controller/UndocumentedController.php
|
||||
type: annotation
|
||||
|
||||
invokable:
|
||||
resource: ../Controller/InvokableController.php
|
||||
type: annotation
|
||||
|
||||
fos_rest:
|
||||
resource: ../Controller/FOSRestController.php
|
||||
type: annotation
|
||||
|
||||
|
||||
# Controllers
|
||||
doc_area:
|
||||
path: /docs/{area}
|
||||
controller: nelmio_api_doc.controller.swagger_ui
|
||||
defaults:
|
||||
area: default
|
||||
|
||||
doc_json:
|
||||
path: /docs.json
|
||||
controller: nelmio_api_doc.controller.swagger_json
|
||||
|
||||
doc_yaml:
|
||||
path: /docs.yaml
|
||||
controller: nelmio_api_doc.controller.swagger_yaml
|
@ -30,6 +30,7 @@ use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
||||
use Symfony\Component\Routing\RouteCollectionBuilder;
|
||||
use Symfony\Component\Serializer\Annotation\SerializedName;
|
||||
|
||||
@ -79,39 +80,43 @@ class TestKernel extends Kernel
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function configureRoutes(RouteCollectionBuilder $routes)
|
||||
protected function configureRoutes($routes)
|
||||
{
|
||||
$routes->import(__DIR__.'/Controller/TestController.php', '/', 'annotation');
|
||||
$routes->import(__DIR__.'/Controller/ApiController.php', '/', 'annotation');
|
||||
$routes->import(__DIR__.'/Controller/ClassApiController.php', '/', 'annotation');
|
||||
$routes->import(__DIR__.'/Controller/UndocumentedController.php', '/', 'annotation');
|
||||
$routes->import(__DIR__.'/Controller/InvokableController.php', '/', 'annotation');
|
||||
$routes->import('', '/api', 'api_platform');
|
||||
$routes->add('/docs/{area}', 'nelmio_api_doc.controller.swagger_ui')->setDefault('area', 'default');
|
||||
$routes->add('/docs.json', 'nelmio_api_doc.controller.swagger_json');
|
||||
$routes->add('/docs.yaml', 'nelmio_api_doc.controller.swagger_yaml');
|
||||
$routes->import(__DIR__.'/Controller/FOSRestController.php', '/', 'annotation');
|
||||
$this->import($routes, '', '/api', 'api_platform');
|
||||
|
||||
$this->import($routes, __DIR__.'/Resources/routes.yaml', '/', 'yaml');
|
||||
|
||||
if (class_exists(SerializedName::class)) {
|
||||
$routes->import(__DIR__.'/Controller/SerializedNameController.php', '/', 'annotation');
|
||||
$this->import($routes, __DIR__.'/Controller/SerializedNameController.php', '/', 'annotation');
|
||||
}
|
||||
|
||||
if ($this->flags & self::USE_JMS) {
|
||||
$routes->import(__DIR__.'/Controller/JMSController.php', '/', 'annotation');
|
||||
$this->import($routes, __DIR__.'/Controller/JMSController.php', '/', 'annotation');
|
||||
}
|
||||
|
||||
if ($this->flags & self::USE_BAZINGA) {
|
||||
$routes->import(__DIR__.'/Controller/BazingaController.php', '/', 'annotation');
|
||||
$this->import($routes, __DIR__.'/Controller/BazingaController.php', '/', 'annotation');
|
||||
|
||||
try {
|
||||
new \ReflectionMethod(Embedded::class, 'getType');
|
||||
$routes->import(__DIR__.'/Controller/BazingaTypedController.php', '/', 'annotation');
|
||||
$this->import($routes, __DIR__.'/Controller/BazingaTypedController.php', '/', 'annotation');
|
||||
} catch (\ReflectionException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->flags & self::ERROR_ARRAY_ITEMS) {
|
||||
$routes->import(__DIR__.'/Controller/ArrayItemsErrorController.php', '/', 'annotation');
|
||||
$this->import($routes, __DIR__.'/Controller/ArrayItemsErrorController.php', '/', 'annotation');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* BC for sf < 5.1.
|
||||
*/
|
||||
private function import($routes, $resource, $prefix, $type) {
|
||||
if ($routes instanceof RoutingConfigurator) {
|
||||
$routes->withPath($prefix)->import($resource, $type);
|
||||
} else {
|
||||
$routes->import($resource, $prefix, $type);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user