remove unused authentication annotation param

This commit is contained in:
Ilyas Salikhov 2024-10-01 18:26:30 +03:00
parent abbf032483
commit e7c9fd4f56
11 changed files with 25 additions and 3274 deletions

View File

@ -130,16 +130,6 @@ class ApiDoc
*/
private $https = false;
/**
* @var bool
*/
private $authentication = false;
/**
* @var array
*/
private $authenticationRoles = [];
/**
* @var int
*/
@ -272,16 +262,6 @@ class ApiDoc
}
}
if (isset($data['authentication'])) {
$this->setAuthentication((bool) $data['authentication']);
}
if (isset($data['authenticationRoles'])) {
foreach ($data['authenticationRoles'] as $key => $role) {
$this->authenticationRoles[] = $role;
}
}
if (isset($data['cache'])) {
$this->setCache($data['cache']);
}
@ -558,38 +538,6 @@ class ApiDoc
$this->https = $https;
}
/**
* @return bool
*/
public function getAuthentication()
{
return $this->authentication;
}
/**
* @param bool $authentication
*/
public function setAuthentication($authentication): void
{
$this->authentication = $authentication;
}
/**
* @return array
*/
public function getAuthenticationRoles()
{
return $this->authenticationRoles;
}
/**
* @param array $authenticationRoles
*/
public function setAuthenticationRoles($authenticationRoles): void
{
$this->authenticationRoles = $authenticationRoles;
}
/**
* @return int
*/
@ -751,8 +699,6 @@ class ApiDoc
}
$data['https'] = $this->https;
$data['authentication'] = $this->authentication;
$data['authenticationRoles'] = $this->authenticationRoles;
$data['deprecated'] = $this->deprecated;
$data['scope'] = $this->scope;

View File

@ -14,9 +14,6 @@
{% if data.https %}
<span class="icon lock" title="HTTPS"></span>
{% endif %}
{% if data.authentication %}
<span class="icon keys" title="Needs {{ data.authenticationRoles|length > 0 ? data.authenticationRoles|join(', ') : 'authentication' }}"></span>
{% endif %}
<span class="path">
{% if data.host is defined -%}

View File

@ -33,9 +33,7 @@ class ApiDocTest extends TestCase
$this->assertFalse(isset($array['requirements']));
$this->assertFalse(isset($array['parameters']));
$this->assertNull($annot->getInput());
$this->assertFalse($array['authentication']);
$this->assertFalse(isset($array['headers']));
$this->assertTrue(is_array($array['authenticationRoles']));
}
public function testConstructWithInvalidData(): void
@ -205,18 +203,6 @@ class ApiDocTest extends TestCase
}
}
public function testConstructWithAuthentication(): void
{
$data = [
'authentication' => true,
];
$annot = new ApiDoc($data);
$array = $annot->toArray();
$this->assertTrue($array['authentication']);
}
public function testConstructWithCache(): void
{
$data = [

View File

@ -17,7 +17,7 @@ use Nelmio\ApiDocBundle\Tests\WebTestCase;
class ApiDocExtractorTest extends WebTestCase
{
private static $ROUTES_QUANTITY_DEFAULT = 28; // Routes in the default view
private static $ROUTES_QUANTITY_DEFAULT = 27; // Routes in the default view
private static $ROUTES_QUANTITY_PREMIUM = 5; // Routes in the premium view
private static $ROUTES_QUANTITY_TEST = 2; // Routes in the test view
@ -161,21 +161,6 @@ class ApiDocExtractorTest extends WebTestCase
);
}
public function testGetWithAuthentication(): void
{
$container = $this->getContainer();
$extractor = $container->get('nelmio_api_doc.extractor.api_doc_extractor');
$annotation = $extractor->get('Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::AuthenticatedAction', 'test_route_13');
$this->assertNotNull($annotation);
$this->assertTrue(
$annotation->getAuthentication()
);
$this->assertContains('ROLE_USER', $annotation->getAuthenticationRoles());
$this->assertContains('ROLE_FOOBAR', $annotation->getAuthenticationRoles());
$this->assertCount(2, $annotation->getAuthenticationRoles());
}
public function testGetWithDeprecated(): void
{
$container = $this->getContainer();

View File

@ -152,16 +152,6 @@ class TestController
{
}
/**
* @ApiDoc(
* authentication=true,
* authenticationRoles={"ROLE_USER","ROLE_FOOBAR"}
* )
*/
public function authenticatedAction(): void
{
}
/**
* @ApiDoc()
*/

View File

@ -47,10 +47,6 @@ test_route_12:
schemes: [https]
defaults: { _controller: Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::secureRouteAction }
test_route_13:
path: /authenticated
defaults: { _controller: Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::authenticatedAction }
test_service_route_1:
path: /tests.{_format}
methods: [GET]

View File

@ -59,8 +59,6 @@ class SimpleFormatterTest extends WebTestCase
'_format' => ['dataType' => '', 'description' => '', 'requirement' => ''],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [],
'deprecated' => false,
'scope' => null,
];

View File

@ -1,947 +0,0 @@
## /api/other-resources ##
### `GET` /api/other-resources.{_format} ###
_List another resource._
#### Requirements ####
**_format**
- Requirement: json|xml|html
#### Response ####
[]:
* type: array of objects (JmsTest)
[][foo]:
* type: string
[][bar]:
* type: DateTime
[][number]:
* type: double
[][arr]:
* type: array
[][nested]:
* type: object (JmsNested)
[][nested][foo]:
* type: DateTime
[][nested][bar]:
* type: string
[][nested][baz][]:
* type: array of integers
* description: Epic description.
With multiple lines.
[][nested][circular]:
* type: object (JmsNested)
[][nested][parent]:
* type: object (JmsTest)
[][nested][parent][foo]:
* type: string
[][nested][parent][bar]:
* type: DateTime
[][nested][parent][number]:
* type: double
[][nested][parent][arr]:
* type: array
[][nested][parent][nested]:
* type: object (JmsNested)
[][nested][parent][nested_array][]:
* type: array of objects (JmsNested)
[][nested][since]:
* type: string
* versions: >=0.2
[][nested][until]:
* type: string
* versions: <=0.3
[][nested][since_and_until]:
* type: string
* versions: >=0.4,<=0.5
[][nested_array][]:
* type: array of objects (JmsNested)
### `PUT|PATCH` /api/other-resources/{id}.{_format} ###
_Update a resource bu ID._
#### Requirements ####
**_format**
- Requirement: json|xml|html
**id**
## /api/resources ##
### `GET` /api/resources.{_format} ###
_List resources._
#### Requirements ####
**_format**
- Requirement: json|xml|html
#### Response ####
tests[]:
* type: array of objects (Test)
tests[][a]:
* type: string
tests[][b]:
* type: DateTime
### `POST` /api/resources.{_format} ###
_Create a new resource._
#### Requirements ####
**_format**
- Requirement: json|xml|html
#### Parameters ####
a:
* type: string
* required: true
* description: Something that describes A.
b:
* type: float
* required: true
c:
* type: choice
* required: true
d:
* type: datetime
* required: true
e:
* type: date
* required: true
g:
* type: string
* required: true
#### Response ####
foo:
* type: DateTime
bar:
* type: string
baz[]:
* type: array of integers
* description: Epic description.
With multiple lines.
circular:
* type: object (JmsNested)
circular[foo]:
* type: DateTime
circular[bar]:
* type: string
circular[baz][]:
* type: array of integers
* description: Epic description.
With multiple lines.
circular[circular]:
* type: object (JmsNested)
circular[parent]:
* type: object (JmsTest)
circular[parent][foo]:
* type: string
circular[parent][bar]:
* type: DateTime
circular[parent][number]:
* type: double
circular[parent][arr]:
* type: array
circular[parent][nested]:
* type: object (JmsNested)
circular[parent][nested_array][]:
* type: array of objects (JmsNested)
circular[since]:
* type: string
* versions: >=0.2
circular[until]:
* type: string
* versions: <=0.3
circular[since_and_until]:
* type: string
* versions: >=0.4,<=0.5
parent:
* type: object (JmsTest)
parent[foo]:
* type: string
parent[bar]:
* type: DateTime
parent[number]:
* type: double
parent[arr]:
* type: array
parent[nested]:
* type: object (JmsNested)
parent[nested_array][]:
* type: array of objects (JmsNested)
since:
* type: string
* versions: >=0.2
until:
* type: string
* versions: <=0.3
since_and_until:
* type: string
* versions: >=0.4,<=0.5
### `DELETE` /api/resources/{id}.{_format} ###
_Delete a resource by ID._
#### Requirements ####
**_format**
- Requirement: json|xml|html
**id**
### `GET` /api/resources/{id}.{_format} ###
_Retrieve a resource by ID._
#### Requirements ####
**_format**
- Requirement: json|xml|html
**id**
## /tests ##
### `GET` /tests.{_format} ###
_index action_
#### Requirements ####
**_format**
#### Filters ####
a:
* DataType: integer
b:
* DataType: string
* Arbitrary: ["arg1","arg2"]
### `GET` /tests.{_format} ###
_index action_
#### Requirements ####
**_format**
#### Filters ####
a:
* DataType: integer
b:
* DataType: string
* Arbitrary: ["arg1","arg2"]
### `POST` /tests.{_format} ###
_create test_
#### Requirements ####
**_format**
#### Parameters ####
a:
* type: string
* required: true
* description: A nice description
b:
* type: string
* required: false
c:
* type: boolean
* required: true
d:
* type: string
* required: true
* default value: DefaultTest
### `POST` /tests.{_format} ###
_create test_
#### Requirements ####
**_format**
#### Parameters ####
a:
* type: string
* required: true
* description: A nice description
b:
* type: string
* required: false
c:
* type: boolean
* required: true
d:
* type: string
* required: true
* default value: DefaultTest
## /tests2 ##
### `POST` /tests2.{_format} ###
_post test 2_
#### Requirements ####
**_format**
## TestResource ##
### `ANY` /named-resource ###
### `POST` /another-post ###
_create another test_
#### Parameters ####
dependency_type:
* type: object (DependencyType)
* required: true
dependency_type[a]:
* type: string
* required: true
* description: A nice description
### `ANY` /any ###
_Action without HTTP verb_
### `ANY` /any/{foo} ###
_Action without HTTP verb_
#### Requirements ####
**foo**
### `ANY` /authenticated ###
### `POST` /jms-input-test ###
_Testing JMS_
#### Parameters ####
foo:
* type: string
* required: false
number:
* type: double
* required: false
arr:
* type: array
* required: false
nested:
* type: object (JmsNested)
* required: false
nested[bar]:
* type: string
* required: false
* default value: baz
nested[baz][]:
* type: array of integers
* required: false
* description: Epic description.
With multiple lines.
nested[circular]:
* type: object (JmsNested)
* required: false
nested[parent]:
* type: object (JmsTest)
* required: false
nested[parent][foo]:
* type: string
* required: false
nested[parent][number]:
* type: double
* required: false
nested[parent][arr]:
* type: array
* required: false
nested[parent][nested]:
* type: object (JmsNested)
* required: false
nested[parent][nested_array][]:
* type: array of objects (JmsNested)
* required: false
nested[since]:
* type: string
* required: false
nested[until]:
* type: string
* required: false
nested[since_and_until]:
* type: string
* required: false
nested_array[]:
* type: array of objects (JmsNested)
* required: false
### `GET` /jms-return-test ###
_Testing return_
#### Response ####
dependency_type:
* type: object (DependencyType)
dependency_type[a]:
* type: string
* description: A nice description
### `ANY` /my-commented/{id}/{page}/{paramType}/{param} ###
_This method is useful to test if the getDocComment works._
This method is useful to test if the getDocComment works.
And, it supports multilines until the first '@' char.
#### Requirements ####
**id**
- Type: int
- Description: A nice comment
**page**
- Type: int
**paramType**
- Type: int
- Description: The param type
**param**
- Type: int
- Description: The param id
### `ANY` /return-nested-output ###
#### Response ####
foo:
* type: string
bar:
* type: DateTime
number:
* type: double
arr:
* type: array
nested:
* type: object (JmsNested)
nested[foo]:
* type: DateTime
nested[bar]:
* type: string
nested[baz][]:
* type: array of integers
* description: Epic description.
With multiple lines.
nested[circular]:
* type: object (JmsNested)
nested[parent]:
* type: object (JmsTest)
nested[parent][foo]:
* type: string
nested[parent][bar]:
* type: DateTime
nested[parent][number]:
* type: double
nested[parent][arr]:
* type: array
nested[parent][nested]:
* type: object (JmsNested)
nested[parent][nested_array][]:
* type: array of objects (JmsNested)
nested[since]:
* type: string
* versions: >=0.2
nested[until]:
* type: string
* versions: <=0.3
nested[since_and_until]:
* type: string
* versions: >=0.4,<=0.5
nested_array[]:
* type: array of objects (JmsNested)
### `GET` /route_with_host.{_format} ###
_Route with host placeholder_
#### Requirements ####
**domain**
- Requirement: test.dev|test.com
**_format**
### `ANY` /secure-route ###
### `ANY` /yet-another/{id} ###
#### Requirements ####
**id**
- Requirement: \d+
### `GET` /z-action-with-deprecated-indicator ###
### This method is deprecated ###
### `POST` /z-action-with-nullable-request-param ###
#### Parameters ####
param1:
* type: string
* required: false
* description: Param1 description.
### `GET` /z-action-with-query-param ###
#### Filters ####
page:
* Requirement: \d+
* Description: Page of the overview.
* Default: 1
### `GET` /z-action-with-query-param-no-default ###
#### Filters ####
page:
* Requirement: \d+
* Description: Page of the overview.
### `GET` /z-action-with-query-param-strict ###
#### Requirements ####
**page**
- Requirement: \d+
- Description: Page of the overview.
### `POST` /z-action-with-request-param ###
#### Parameters ####
param1:
* type: string
* required: true
* description: Param1 description.
### `ANY` /z-return-jms-and-validator-output ###
#### Response ####
bar:
* type: DateTime
objects[]:
* type: array of objects (Test)
objects[][a]:
* type: string
objects[][b]:
* type: DateTime
number:
* type: DateTime
related:
* type: object (Test)
related[a]:
* type: string
related[b]:
* type: DateTime
### `ANY` /z-return-selected-parsers-input ###
#### Parameters ####
a:
* type: string
* required: true
* description: A nice description
b:
* type: string
* required: false
c:
* type: boolean
* required: true
d:
* type: string
* required: true
* default value: DefaultTest
### `ANY` /z-return-selected-parsers-output ###
#### Response ####
bar:
* type: DateTime
objects[]:
* type: array of objects (Test)
objects[][a]:
* type: string
objects[][b]:
* type: DateTime
number:
* type: DateTime
related:
* type: object (Test)
related[a]:
* type: string
related[b]:
* type: DateTime
### `POST` /zcached ###
### `POST` /zsecured ###
### `GET` /zz-tests-route-version.{_format} ###
#### Requirements ####
**_format**

File diff suppressed because it is too large Load Diff

View File

@ -442,10 +442,6 @@ _Action without HTTP verb_
### `ANY` /authenticated ###
### `POST` /jms-input-test ###
_Testing JMS_

View File

@ -286,9 +286,6 @@ With multiple lines.',
],
'resourceDescription' => 'Operations on another resource.',
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
@ -309,9 +306,6 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
@ -381,9 +375,6 @@ With multiple lines.',
],
'resourceDescription' => 'Operations on resource.',
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
@ -820,9 +811,6 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
@ -843,9 +831,6 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
@ -866,9 +851,6 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
@ -898,9 +880,6 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
@ -959,9 +938,6 @@ With multiple lines.',
1 => 'premium',
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
@ -983,9 +959,6 @@ With multiple lines.',
1 => 'premium',
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
@ -998,9 +971,6 @@ With multiple lines.',
0 => 'default',
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
@ -1037,9 +1007,6 @@ With multiple lines.',
1 => 'test',
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
@ -1055,25 +1022,10 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
2 => [
'method' => 'ANY',
'uri' => '/authenticated',
'https' => false,
'authentication' => true,
'authenticationRoles' => [
0 => 'ROLE_USER',
1 => 'ROLE_FOOBAR',
],
'deprecated' => false,
'scope' => null,
],
3 => [
'method' => 'POST',
'uri' => '/jms-input-test',
'description' => 'Testing JMS',
@ -1334,13 +1286,10 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
4 => [
3 => [
'method' => 'GET',
'uri' => '/jms-return-test',
'description' => 'Testing return',
@ -1367,13 +1316,10 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
5 => [
4 => [
'method' => 'ANY',
'uri' => '/my-commented/{id}/{page}/{paramType}/{param}',
'description' => 'This method is useful to test if the getDocComment works.',
@ -1402,13 +1348,10 @@ And, it supports multilines until the first \'@\' char.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
6 => [
5 => [
'method' => 'ANY',
'uri' => '/return-nested-output',
'response' => [
@ -1668,13 +1611,10 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
7 => [
6 => [
'method' => 'GET',
'uri' => '/route_with_host.{_format}',
'host' => 'api.test.dev',
@ -1695,34 +1635,25 @@ With multiple lines.',
0 => 'default',
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
'deprecated' => false,
'scope' => null,
],
7 => [
'method' => 'ANY',
'uri' => '/secure-route',
'https' => true,
'deprecated' => false,
'scope' => null,
],
8 => [
'method' => 'ANY',
'uri' => '/secure-route',
'https' => true,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
9 => [
'method' => 'GET',
'uri' => '/with-link',
'link' => 'http://symfony.com',
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
10 => [
9 => [
'method' => 'ANY',
'uri' => '/yet-another/{id}',
'requirements' => [
@ -1733,23 +1664,17 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
11 => [
10 => [
'method' => 'GET',
'uri' => '/z-action-with-deprecated-indicator',
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => true,
'scope' => null,
],
12 => [
11 => [
'method' => 'ANY',
'uri' => '/z-return-jms-and-validator-output',
'response' => [
@ -1863,13 +1788,10 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
13 => [
12 => [
'method' => 'ANY',
'uri' => '/z-return-selected-parsers-input',
'parameters' => [
@ -1911,13 +1833,10 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
14 => [
13 => [
'method' => 'ANY',
'uri' => '/z-return-selected-parsers-output',
'response' => [
@ -2031,33 +1950,24 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
'deprecated' => false,
'scope' => null,
],
14 => [
'method' => 'POST',
'uri' => '/zcached',
'https' => false,
'deprecated' => false,
'scope' => null,
],
15 => [
'method' => 'POST',
'uri' => '/zcached',
'uri' => '/zsecured',
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
16 => [
'method' => 'POST',
'uri' => '/zsecured',
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
17 => [
'method' => 'GET',
'uri' => '/zz-tests-route-version.{_format}',
'requirements' => [
@ -2068,9 +1978,6 @@ With multiple lines.',
],
],
'https' => false,
'authentication' => false,
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],