mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Symfony 6 compability
This commit is contained in:
parent
72441d6bf3
commit
5cbcba78df
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -17,6 +17,7 @@ jobs:
|
|||||||
- '8.1'
|
- '8.1'
|
||||||
symfony-version:
|
symfony-version:
|
||||||
- '5.4.*'
|
- '5.4.*'
|
||||||
|
- '6.4.*'
|
||||||
coverage: [ 'none' ]
|
coverage: [ 'none' ]
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout"
|
- name: "Checkout"
|
||||||
|
@ -18,7 +18,8 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Contracts\Translation\LocaleAwareInterface;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
#[AsCommand(
|
#[AsCommand(
|
||||||
name: 'api:doc:dump',
|
name: 'api:doc:dump',
|
||||||
@ -31,8 +32,12 @@ class DumpCommand extends Command
|
|||||||
*/
|
*/
|
||||||
protected $availableFormats = array('markdown', 'json', 'html');
|
protected $availableFormats = array('markdown', 'json', 'html');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TranslatorInterface&LocaleAwareInterface $translator
|
||||||
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private ContainerInterface $container,
|
private ContainerInterface $container,
|
||||||
|
private TranslatorInterface $translator,
|
||||||
string $name = null
|
string $name = null
|
||||||
) {
|
) {
|
||||||
parent::__construct($name);
|
parent::__construct($name);
|
||||||
@ -58,9 +63,7 @@ class DumpCommand extends Command
|
|||||||
$format = $input->getOption('format');
|
$format = $input->getOption('format');
|
||||||
$view = $input->getOption('view');
|
$view = $input->getOption('view');
|
||||||
|
|
||||||
$routeCollection = $this->container->get('router')->getRouteCollection();
|
if ($format === 'json') {
|
||||||
|
|
||||||
if ($format == 'json') {
|
|
||||||
$formatter = $this->container->get('nelmio_api_doc.formatter.simple_formatter');
|
$formatter = $this->container->get('nelmio_api_doc.formatter.simple_formatter');
|
||||||
} else {
|
} else {
|
||||||
if (!in_array($format, $this->availableFormats)) {
|
if (!in_array($format, $this->availableFormats)) {
|
||||||
@ -71,7 +74,7 @@ class DumpCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($input->hasOption('locale')) {
|
if ($input->hasOption('locale')) {
|
||||||
$this->container->get('translator')->setLocale($input->getOption('locale') ?? '');
|
$this->translator->setLocale($input->getOption('locale') ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($input->hasOption('api-version')) {
|
if ($input->hasOption('api-version')) {
|
||||||
@ -82,11 +85,6 @@ class DumpCommand extends Command
|
|||||||
$formatter->setEnableSandbox(false);
|
$formatter->setEnableSandbox(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('html' === $format && method_exists($this->container, 'enterScope')) {
|
|
||||||
$this->container->enterScope('request');
|
|
||||||
$this->container->set('request', new Request(), 'request');
|
|
||||||
}
|
|
||||||
|
|
||||||
$extractor = $this->container->get('nelmio_api_doc.extractor.api_doc_extractor');
|
$extractor = $this->container->get('nelmio_api_doc.extractor.api_doc_extractor');
|
||||||
$extractedDoc = $input->hasOption('api-version') ?
|
$extractedDoc = $input->hasOption('api-version') ?
|
||||||
$extractor->allForVersion($input->getOption('api-version'), $view) :
|
$extractor->allForVersion($input->getOption('api-version'), $view) :
|
||||||
|
@ -19,7 +19,7 @@ class ApiDocExtractorTest extends WebTestCase
|
|||||||
{
|
{
|
||||||
const NB_ROUTES_ADDED_BY_DUNGLAS_API_BUNDLE = 5;
|
const NB_ROUTES_ADDED_BY_DUNGLAS_API_BUNDLE = 5;
|
||||||
|
|
||||||
private static $ROUTES_QUANTITY_DEFAULT = 37; // Routes in the default view
|
private static $ROUTES_QUANTITY_DEFAULT = 36; // Routes in the default view
|
||||||
private static $ROUTES_QUANTITY_PREMIUM = 5; // Routes in the premium view
|
private static $ROUTES_QUANTITY_PREMIUM = 5; // Routes in the premium view
|
||||||
private static $ROUTES_QUANTITY_TEST = 2; // Routes in the test view
|
private static $ROUTES_QUANTITY_TEST = 2; // Routes in the test view
|
||||||
|
|
||||||
|
@ -158,24 +158,6 @@ class FosRestHandlerTest extends WebTestCase
|
|||||||
$this->assertArrayNotHasKey('default', $parameter);
|
$this->assertArrayNotHasKey('default', $parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPostWithArrayRequestParam()
|
|
||||||
{
|
|
||||||
$container = $this->getContainer();
|
|
||||||
$extractor = $container->get('nelmio_api_doc.extractor.api_doc_extractor');
|
|
||||||
$annotation = $extractor->get('Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::zActionWithArrayRequestParamAction', 'test_route_26');
|
|
||||||
|
|
||||||
$this->assertNotNull($annotation);
|
|
||||||
|
|
||||||
$parameters = $annotation->getParameters();
|
|
||||||
$this->assertCount(1, $parameters);
|
|
||||||
$this->assertArrayHasKey('param1', $parameters);
|
|
||||||
|
|
||||||
$parameter = $parameters['param1'];
|
|
||||||
|
|
||||||
$this->assertArrayHasKey('dataType', $parameter);
|
|
||||||
$this->assertEquals('string[]', $parameter['dataType']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testWithRequestParamArrayRequirements()
|
public function testWithRequestParamArrayRequirements()
|
||||||
{
|
{
|
||||||
$container = $this->getContainer();
|
$container = $this->getContainer();
|
||||||
|
@ -200,14 +200,6 @@ class TestController
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @ApiDoc()
|
|
||||||
* @RequestParamHelper(name="param1", requirements="string", array=true)
|
|
||||||
*/
|
|
||||||
public function zActionWithArrayRequestParamAction()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ApiDoc()
|
* @ApiDoc()
|
||||||
*/
|
*/
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Nelmio\ApiDocBundle\Tests\Fixtures;
|
|
||||||
|
|
||||||
use FOS\RestBundle\Controller\Annotations\RequestParam;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* For BC FOSRestBundle < 2.0
|
|
||||||
*
|
|
||||||
* @Annotation
|
|
||||||
* @Target("METHOD")
|
|
||||||
*
|
|
||||||
* @author Ener-Getick
|
|
||||||
*/
|
|
||||||
class RequestParamHelper extends RequestParam
|
|
||||||
{
|
|
||||||
public function __construct(array $data)
|
|
||||||
{
|
|
||||||
foreach ($data as $key => $value) {
|
|
||||||
if ($key === 'array') {
|
|
||||||
if (property_exists($this, 'map')) {
|
|
||||||
$this->map = $value;
|
|
||||||
} else {
|
|
||||||
$this->array = $value;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$this->$key = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -8,8 +8,6 @@ framework:
|
|||||||
enabled: true
|
enabled: true
|
||||||
test: ~
|
test: ~
|
||||||
default_locale: en
|
default_locale: en
|
||||||
session:
|
|
||||||
storage_id: session.storage.mock_file
|
|
||||||
profiler: { only_exceptions: false }
|
profiler: { only_exceptions: false }
|
||||||
annotations: ~
|
annotations: ~
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class MarkdownFormatterTest extends WebTestCase
|
|||||||
$expected = str_replace('DependencyType', 'dependency_type', $expected);
|
$expected = str_replace('DependencyType', 'dependency_type', $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result . "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormatOne()
|
public function testFormatOne()
|
||||||
|
@ -704,17 +704,6 @@ _Route with host placeholder_
|
|||||||
- Requirement: \d+
|
- Requirement: \d+
|
||||||
|
|
||||||
|
|
||||||
### `POST` /z-action-with-array-request-param ###
|
|
||||||
|
|
||||||
|
|
||||||
#### Parameters ####
|
|
||||||
|
|
||||||
param1:
|
|
||||||
|
|
||||||
* type: string[]
|
|
||||||
* required: true
|
|
||||||
|
|
||||||
|
|
||||||
### `GET` /z-action-with-deprecated-indicator ###
|
### `GET` /z-action-with-deprecated-indicator ###
|
||||||
### This method is deprecated ###
|
### This method is deprecated ###
|
||||||
|
|
||||||
@ -928,4 +917,4 @@ related[b]:
|
|||||||
|
|
||||||
#### Requirements ####
|
#### Requirements ####
|
||||||
|
|
||||||
**_format**
|
**_format**
|
||||||
|
@ -1942,30 +1942,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
11 =>
|
11 =>
|
||||||
array (
|
|
||||||
'method' => 'POST',
|
|
||||||
'uri' => '/z-action-with-array-request-param',
|
|
||||||
'parameters' =>
|
|
||||||
array (
|
|
||||||
'param1' =>
|
|
||||||
array (
|
|
||||||
'required' => true,
|
|
||||||
'dataType' => 'string[]',
|
|
||||||
'actualType' => 'string',
|
|
||||||
'subType' => NULL,
|
|
||||||
'description' => NULL,
|
|
||||||
'readonly' => false,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'https' => false,
|
|
||||||
'authentication' => false,
|
|
||||||
'authenticationRoles' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'deprecated' => false,
|
|
||||||
),
|
|
||||||
12 =>
|
|
||||||
array (
|
array (
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'uri' => '/z-action-with-deprecated-indicator',
|
'uri' => '/z-action-with-deprecated-indicator',
|
||||||
@ -1976,7 +1953,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => true,
|
'deprecated' => true,
|
||||||
),
|
),
|
||||||
13 =>
|
12 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'uri' => '/z-action-with-nullable-request-param',
|
'uri' => '/z-action-with-nullable-request-param',
|
||||||
@ -1999,7 +1976,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
14 =>
|
13 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'uri' => '/z-action-with-query-param',
|
'uri' => '/z-action-with-query-param',
|
||||||
@ -2019,7 +1996,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
15 =>
|
14 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'uri' => '/z-action-with-query-param-no-default',
|
'uri' => '/z-action-with-query-param-no-default',
|
||||||
@ -2038,7 +2015,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
16 =>
|
15 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'uri' => '/z-action-with-query-param-strict',
|
'uri' => '/z-action-with-query-param-strict',
|
||||||
@ -2058,7 +2035,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
17 =>
|
16 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'uri' => '/z-action-with-request-param',
|
'uri' => '/z-action-with-request-param',
|
||||||
@ -2081,7 +2058,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
18 =>
|
17 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'uri' => '/z-query-param-array-requirements',
|
'uri' => '/z-query-param-array-requirements',
|
||||||
@ -2100,7 +2077,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
19 =>
|
18 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'uri' => '/z-query-param-plain-array-requirements',
|
'uri' => '/z-query-param-plain-array-requirements',
|
||||||
@ -2119,7 +2096,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
20 =>
|
19 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'uri' => '/z-query-requirement-param-not-set',
|
'uri' => '/z-query-requirement-param-not-set',
|
||||||
@ -2137,7 +2114,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
21 =>
|
20 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'ANY',
|
'method' => 'ANY',
|
||||||
'uri' => '/z-return-jms-and-validator-output',
|
'uri' => '/z-return-jms-and-validator-output',
|
||||||
@ -2275,7 +2252,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
22 =>
|
21 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'ANY',
|
'method' => 'ANY',
|
||||||
'uri' => '/z-return-selected-parsers-input',
|
'uri' => '/z-return-selected-parsers-input',
|
||||||
@ -2329,7 +2306,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
23 =>
|
22 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'ANY',
|
'method' => 'ANY',
|
||||||
'uri' => '/z-return-selected-parsers-output',
|
'uri' => '/z-return-selected-parsers-output',
|
||||||
@ -2467,7 +2444,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
24 =>
|
23 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'uri' => '/zcached',
|
'uri' => '/zcached',
|
||||||
@ -2479,7 +2456,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
25 =>
|
24 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'uri' => '/zsecured',
|
'uri' => '/zsecured',
|
||||||
@ -2490,7 +2467,7 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
26 =>
|
25 =>
|
||||||
array (
|
array (
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'uri' => '/zz-tests-route-version.{_format}',
|
'uri' => '/zz-tests-route-version.{_format}',
|
||||||
@ -2511,4 +2488,4 @@ With multiple lines.',
|
|||||||
'deprecated' => false,
|
'deprecated' => false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -15,6 +15,7 @@ use PHPUnit\Util\ErrorHandler;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\HttpKernel\Kernel;
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
|
|
||||||
abstract class WebTestCase extends BaseWebTestCase
|
abstract class WebTestCase extends BaseWebTestCase
|
||||||
{
|
{
|
||||||
@ -38,35 +39,14 @@ abstract class WebTestCase extends BaseWebTestCase
|
|||||||
return ErrorHandler::handleError($errorNumber, $message, $file, $line);
|
return ErrorHandler::handleError($errorNumber, $message, $file, $line);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected static function getKernelClass(): string
|
||||||
* @param array $options
|
|
||||||
* @return ContainerInterface
|
|
||||||
*/
|
|
||||||
protected static function getContainer(array $options = array()): ContainerInterface
|
|
||||||
{
|
|
||||||
if (!static::$kernel) {
|
|
||||||
static::$kernel = static::createKernel($options);
|
|
||||||
}
|
|
||||||
|
|
||||||
static::$kernel->boot();
|
|
||||||
|
|
||||||
if (!static::$container) {
|
|
||||||
static::$container = static::$kernel->getContainer();
|
|
||||||
}
|
|
||||||
|
|
||||||
static::$container->set('kernel', static::$kernel);
|
|
||||||
|
|
||||||
return static::$container;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function getKernelClass()
|
|
||||||
{
|
{
|
||||||
require_once __DIR__.'/Fixtures/app/AppKernel.php';
|
require_once __DIR__.'/Fixtures/app/AppKernel.php';
|
||||||
|
|
||||||
return 'Nelmio\ApiDocBundle\Tests\Functional\AppKernel';
|
return 'Nelmio\ApiDocBundle\Tests\Functional\AppKernel';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function createKernel(array $options = array())
|
protected static function createKernel(array $options = array()): KernelInterface
|
||||||
{
|
{
|
||||||
$class = self::getKernelClass();
|
$class = self::getKernelClass();
|
||||||
|
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.1",
|
"php": ">=8.1",
|
||||||
"symfony/form": "^5.0",
|
"symfony/form": "^5.0|^6.0",
|
||||||
"symfony/twig-bundle": "^5.0",
|
"symfony/twig-bundle": "^5.0|^6.0",
|
||||||
"symfony/framework-bundle": "^5.0",
|
"symfony/framework-bundle": "^5.0|^6.0",
|
||||||
"symfony/console": "^5.0",
|
"symfony/console": "^5.0|^6.0",
|
||||||
"michelf/php-markdown": "~1.4"
|
"michelf/php-markdown": "~1.4"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
@ -28,11 +28,11 @@
|
|||||||
"jms/serializer-bundle": "4.1.0",
|
"jms/serializer-bundle": "4.1.0",
|
||||||
"phpunit/phpunit": "~9.5",
|
"phpunit/phpunit": "~9.5",
|
||||||
"sensio/framework-extra-bundle": "^6.2",
|
"sensio/framework-extra-bundle": "^6.2",
|
||||||
"symfony/asset": "^5.0",
|
"symfony/asset": "^5.0|^6.0",
|
||||||
"symfony/browser-kit": "^5.0",
|
"symfony/browser-kit": "^5.0|^6.0",
|
||||||
"symfony/translation": "^5.0",
|
"symfony/translation": "^5.0|^6.0",
|
||||||
"symfony/validator": "^5.0",
|
"symfony/validator": "^5.0|^6.0",
|
||||||
"symfony/yaml": "^5.0"
|
"symfony/yaml": "^5.0|^6.0"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"jms/serializer": "<0.12",
|
"jms/serializer": "<0.12",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user