mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Merge pull request #1933 from nelmio/SF6
Use an early version of Api-platform with symfony 6 support in one test case
This commit is contained in:
commit
3d263a525d
11
.github/workflows/continuous-integration.yml
vendored
11
.github/workflows/continuous-integration.yml
vendored
@ -34,6 +34,9 @@ jobs:
|
||||
symfony-require: "5.4.*"
|
||||
- php-version: 8.1
|
||||
symfony-require: "5.4.*"
|
||||
- php-version: 8.1
|
||||
symfony-require: "6.0.*"
|
||||
api-platform: "early"
|
||||
|
||||
steps:
|
||||
- name: "Checkout"
|
||||
@ -59,6 +62,14 @@ jobs:
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
|
||||
- name: "Use an early version of Api-platform with symfony 6 support"
|
||||
if: ${{ matrix.api-platform == 'early' }}
|
||||
env:
|
||||
SYMFONY_REQUIRE: "${{ matrix.symfony-require }}"
|
||||
run: |
|
||||
composer config repositories.api-platform git https://github.com/PierreRebeilleau/core.git
|
||||
composer require api-platform/core:dev-test-compatibility --no-update --dev
|
||||
|
||||
- name: "Install dependencies with composer"
|
||||
env:
|
||||
SYMFONY_REQUIRE: "${{ matrix.symfony-require }}"
|
||||
|
45
Tests/Functional/Resources/routes.yaml
Normal file
45
Tests/Functional/Resources/routes.yaml
Normal file
@ -0,0 +1,45 @@
|
||||
# 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
|
||||
|
||||
|
||||
api_platform:
|
||||
resource: .
|
||||
prefix: /api
|
||||
type: api_platform
|
||||
|
||||
# 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,7 +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\RouteCollectionBuilder;
|
||||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
||||
use Symfony\Component\Serializer\Annotation\SerializedName;
|
||||
|
||||
class TestKernel extends Kernel
|
||||
@ -79,39 +79,42 @@ 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, __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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional;
|
||||
use OpenApi\Annotations as OA;
|
||||
use OpenApi\Generator;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
class WebTestCase extends BaseWebTestCase
|
||||
@ -168,4 +169,16 @@ class WebTestCase extends BaseWebTestCase
|
||||
sprintf('Failed asserting that property "%s" does not exist.', $property)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* BC symfony < 5.3.
|
||||
*/
|
||||
protected static function getContainer(): ContainerInterface
|
||||
{
|
||||
if (method_exists(parent::class, 'getContainer')) {
|
||||
return parent::getContainer();
|
||||
}
|
||||
|
||||
return static::$container;
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class GetNelmioAssetTest extends WebTestCase
|
||||
{
|
||||
static::bootKernel();
|
||||
/** @var GetNelmioAsset $getNelmioAsset */
|
||||
$getNelmioAsset = static::$container->get('nelmio_api_doc.render_docs.html.asset');
|
||||
$getNelmioAsset = static::getContainer()->get('nelmio_api_doc.render_docs.html.asset');
|
||||
/** @var TwigFunction */
|
||||
$twigFunction = $getNelmioAsset->getFunctions()[0];
|
||||
self::assertSame($expectedContent, $twigFunction->getCallable()->__invoke($mode, $asset));
|
||||
|
@ -21,32 +21,32 @@
|
||||
"psr/cache": "^1.0|^2.0|^3.0",
|
||||
"psr/container": "^1.0|^2.0",
|
||||
"psr/log": "^1.0|^2.0|^3.0",
|
||||
"symfony/config": "^4.4|^5.0",
|
||||
"symfony/console": "^4.4|^5.0",
|
||||
"symfony/dependency-injection": "^4.4|^5.0",
|
||||
"symfony/framework-bundle": "^4.4|^5.0",
|
||||
"symfony/http-foundation": "^4.4|^5.0",
|
||||
"symfony/http-kernel": "^4.4|^5.0",
|
||||
"symfony/options-resolver": "^4.4|^5.0",
|
||||
"symfony/property-info": "^4.4|^5.0",
|
||||
"symfony/routing": "^4.4|^5.0",
|
||||
"symfony/config": "^4.4|^5.0|^6.0",
|
||||
"symfony/console": "^4.4|^5.0|^6.0",
|
||||
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
|
||||
"symfony/framework-bundle": "^4.4|^5.0|^6.0",
|
||||
"symfony/http-foundation": "^4.4|^5.0|^6.0",
|
||||
"symfony/http-kernel": "^4.4|^5.0|^6.0",
|
||||
"symfony/options-resolver": "^4.4|^5.0|^6.0",
|
||||
"symfony/property-info": "^4.4|^5.0|^6.0",
|
||||
"symfony/routing": "^4.4|^5.0|^6.0",
|
||||
"zircote/swagger-php": "^3.2|^4.0",
|
||||
"phpdocumentor/reflection-docblock": "^3.1|^4.4|^5.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"sensio/framework-extra-bundle": "^4.4|^5.0|^6.0",
|
||||
"symfony/asset": "^4.4|^5.0",
|
||||
"symfony/dom-crawler": "^4.4|^5.0",
|
||||
"symfony/browser-kit": "^4.4|^5.0",
|
||||
"symfony/cache": "^4.4|^5.0",
|
||||
"symfony/form": "^4.4|^5.0",
|
||||
"sensio/framework-extra-bundle": "^4.4|^5.2|^6.0",
|
||||
"symfony/asset": "^4.4|^5.2|^6.0",
|
||||
"symfony/dom-crawler": "^4.4|^5.2|^6.0",
|
||||
"symfony/browser-kit": "^4.4|^5.2|^6.0",
|
||||
"symfony/cache": "^4.4|^5.2|^6.0",
|
||||
"symfony/form": "^4.4|^5.2|^6.0",
|
||||
"symfony/phpunit-bridge": "^5.2",
|
||||
"symfony/property-access": "^4.4|^5.0",
|
||||
"symfony/serializer": "^4.4|^5.0",
|
||||
"symfony/stopwatch": "^4.4|^5.0",
|
||||
"symfony/templating": "^4.4|^5.0",
|
||||
"symfony/twig-bundle": "^4.4|^5.0",
|
||||
"symfony/validator": "^4.4|^5.0",
|
||||
"symfony/property-access": "^4.4|^5.2|^6.0",
|
||||
"symfony/serializer": "^4.4|^5.2|^6.0",
|
||||
"symfony/stopwatch": "^4.4|^5.2|^6.0",
|
||||
"symfony/templating": "^4.4|^5.2|^6.0",
|
||||
"symfony/twig-bundle": "^4.4|^5.2|^6.0",
|
||||
"symfony/validator": "^4.4|^5.2|^6.0",
|
||||
|
||||
"api-platform/core": "^2.4",
|
||||
"friendsofsymfony/rest-bundle": "^2.8|^3.0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user