diff --git a/Annotation/ApiDoc.php b/Annotation/ApiDoc.php index d45dfe0a0..86d5b64e8 100644 --- a/Annotation/ApiDoc.php +++ b/Annotation/ApiDoc.php @@ -175,6 +175,8 @@ class ApiDoc */ private $tags = []; + private ?string $scope = null; + public function __construct(array $data) { $this->resource = !empty($data['resource']) ? $data['resource'] : false; @@ -664,6 +666,16 @@ public function getMethod() return $this->method; } + public function setScope(string $scope): void + { + $this->scope = $scope; + } + + public function getScope(): ?string + { + return $this->scope; + } + /** * @return array */ @@ -742,6 +754,7 @@ public function toArray() $data['authentication'] = $this->authentication; $data['authenticationRoles'] = $this->authenticationRoles; $data['deprecated'] = $this->deprecated; + $data['scope'] = $this->scope; return $data; } diff --git a/Extractor/ApiDocExtractor.php b/Extractor/ApiDocExtractor.php index 752438a39..ae4e1aba2 100644 --- a/Extractor/ApiDocExtractor.php +++ b/Extractor/ApiDocExtractor.php @@ -506,10 +506,13 @@ protected function setParentClasses($array) if (isset($v['children'])) { if (isset($v['class'])) { foreach ($v['children'] as $key => $item) { - $array[$k]['children'][$key]['parentClass'] = $v['class']; + if (empty($item['parentClass'] ?? null)) { + $array[$k]['children'][$key]['parentClass'] = $v['class']; + } $array[$k]['children'][$key]['field'] = $key; } } + $array[$k]['children'] = $this->setParentClasses($array[$k]['children']); } } diff --git a/Tests/Formatter/SimpleFormatterTest.php b/Tests/Formatter/SimpleFormatterTest.php index d9b3c5e98..ce2da43c3 100644 --- a/Tests/Formatter/SimpleFormatterTest.php +++ b/Tests/Formatter/SimpleFormatterTest.php @@ -62,6 +62,7 @@ public function testFormatOne(): void 'authentication' => false, 'authenticationRoles' => [], 'deprecated' => false, + 'scope' => null, ]; $this->assertEquals($expected, $result); diff --git a/Tests/Formatter/testFormat-result.php b/Tests/Formatter/testFormat-result.php index 098ef8eed..de5b26ba7 100644 --- a/Tests/Formatter/testFormat-result.php +++ b/Tests/Formatter/testFormat-result.php @@ -1114,6 +1114,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, 'views' => [ 'default', 'test', @@ -1128,6 +1129,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 2 => [ 'method' => 'ANY', @@ -1145,6 +1147,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 3 => [ 'method' => 'ANY', @@ -1156,6 +1159,7 @@ 1 => 'ROLE_FOOBAR', ], 'deprecated' => false, + 'scope' => null, ], 4 => [ 'method' => 'POST', @@ -1422,6 +1426,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 5 => [ 'method' => 'GET', @@ -1456,6 +1461,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 6 => [ 'method' => 'ANY', @@ -1490,6 +1496,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 7 => [ 'method' => 'GET', @@ -1509,6 +1516,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, 'resourceDescription' => 'Popo', 'section' => 'Popo', ], @@ -1538,6 +1546,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, 'resourceDescription' => 'Popo', 'section' => 'Popo', ], @@ -1558,6 +1567,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, 'resourceDescription' => 'Popo', 'section' => 'Popo', ], @@ -1586,6 +1596,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, 'resourceDescription' => 'Popo', 'section' => 'Popo', ], @@ -1622,6 +1633,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, 'resourceDescription' => 'Popo', 'section' => 'Popo', ], @@ -1889,6 +1901,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 13 => [ 'method' => 'GET', @@ -1915,6 +1928,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 14 => [ 'method' => 'ANY', @@ -1924,6 +1938,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 15 => [ 'method' => 'ANY', @@ -1940,6 +1955,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 16 => [ 'method' => 'GET', @@ -1949,6 +1965,7 @@ 'authenticationRoles' => [ ], 'deprecated' => true, + 'scope' => null, ], 17 => [ 'method' => 'POST', @@ -1968,6 +1985,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 18 => [ 'method' => 'GET', @@ -1984,6 +2002,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 19 => [ 'method' => 'GET', @@ -1999,6 +2018,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 20 => [ 'method' => 'GET', @@ -2034,6 +2054,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 22 => [ 'method' => 'ANY', @@ -2135,6 +2156,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 23 => [ 'method' => 'ANY', @@ -2182,6 +2204,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 24 => [ 'method' => 'ANY', @@ -2283,6 +2306,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 25 => [ 'method' => 'POST', @@ -2292,6 +2316,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 26 => [ 'method' => 'POST', @@ -2301,6 +2326,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 27 => [ 'authentication' => false, @@ -2309,6 +2335,7 @@ 'https' => false, 'authenticationRoles' => [], 'deprecated' => false, + 'scope' => null, 'requirements' => [ '_format' => [ 'requirement' => '', diff --git a/Tests/Formatter/testFormat-result_1.php b/Tests/Formatter/testFormat-result_1.php index 28f60767e..a92292e10 100644 --- a/Tests/Formatter/testFormat-result_1.php +++ b/Tests/Formatter/testFormat-result_1.php @@ -290,6 +290,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 1 => [ 'method' => 'PUT|PATCH', @@ -312,6 +313,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], ], '/api/resources' => [ @@ -383,6 +385,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 1 => [ 'method' => 'POST', @@ -821,6 +824,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 2 => [ 'method' => 'DELETE', @@ -843,6 +847,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 3 => [ 'method' => 'GET', @@ -865,6 +870,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], ], '/tests' => [ @@ -896,6 +902,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 1 => [ 'method' => 'POST', @@ -956,6 +963,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], ], '/tests2' => [ @@ -979,6 +987,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], ], 'TestResource' => [ @@ -993,6 +1002,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], ], 'others' => [ @@ -1031,6 +1041,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 1 => [ 'method' => 'ANY', @@ -1048,6 +1059,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 2 => [ 'method' => 'ANY', @@ -1059,6 +1071,7 @@ 1 => 'ROLE_FOOBAR', ], 'deprecated' => false, + 'scope' => null, ], 3 => [ 'method' => 'POST', @@ -1325,6 +1338,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 4 => [ 'method' => 'GET', @@ -1357,6 +1371,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 5 => [ 'method' => 'ANY', @@ -1391,6 +1406,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 6 => [ 'method' => 'ANY', @@ -1656,6 +1672,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 7 => [ 'method' => 'GET', @@ -1682,6 +1699,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 8 => [ 'method' => 'ANY', @@ -1691,6 +1709,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 9 => [ 'method' => 'GET', @@ -1701,6 +1720,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 10 => [ 'method' => 'ANY', @@ -1717,6 +1737,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 11 => [ 'method' => 'GET', @@ -1726,6 +1747,7 @@ 'authenticationRoles' => [ ], 'deprecated' => true, + 'scope' => null, ], 12 => [ 'method' => 'POST', @@ -1745,6 +1767,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 13 => [ 'method' => 'GET', @@ -1761,6 +1784,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 14 => [ 'method' => 'GET', @@ -1776,6 +1800,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 15 => [ 'method' => 'GET', @@ -1792,6 +1817,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 16 => [ 'method' => 'POST', @@ -1811,6 +1837,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 17 => [ 'method' => 'GET', @@ -1826,6 +1853,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 18 => [ 'method' => 'GET', @@ -1841,6 +1869,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 19 => [ 'method' => 'GET', @@ -1855,6 +1884,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 20 => [ 'method' => 'ANY', @@ -1974,6 +2004,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 21 => [ 'method' => 'ANY', @@ -2021,6 +2052,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 22 => [ 'method' => 'ANY', @@ -2140,6 +2172,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 23 => [ 'method' => 'POST', @@ -2149,6 +2182,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 24 => [ 'method' => 'POST', @@ -2158,6 +2192,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], 25 => [ 'method' => 'GET', @@ -2174,6 +2209,7 @@ 'authenticationRoles' => [ ], 'deprecated' => false, + 'scope' => null, ], ], ];