Skip to content

Commit

Permalink
add scope field to ApiDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
muxx committed Oct 1, 2024
1 parent 5513664 commit d761d89
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Annotation/ApiDoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion Extractor/ApiDocExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}
Expand Down
1 change: 1 addition & 0 deletions Tests/Formatter/SimpleFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function testFormatOne(): void
'authentication' => false,
'authenticationRoles' => [],
'deprecated' => false,
'scope' => null,
];

$this->assertEquals($expected, $result);
Expand Down
27 changes: 27 additions & 0 deletions Tests/Formatter/testFormat-result.php
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
'views' => [
'default',
'test',
Expand All @@ -1128,6 +1129,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
2 => [
'method' => 'ANY',
Expand All @@ -1145,6 +1147,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
3 => [
'method' => 'ANY',
Expand All @@ -1156,6 +1159,7 @@
1 => 'ROLE_FOOBAR',
],
'deprecated' => false,
'scope' => null,
],
4 => [
'method' => 'POST',
Expand Down Expand Up @@ -1422,6 +1426,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
5 => [
'method' => 'GET',
Expand Down Expand Up @@ -1456,6 +1461,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
6 => [
'method' => 'ANY',
Expand Down Expand Up @@ -1490,6 +1496,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
7 => [
'method' => 'GET',
Expand All @@ -1509,6 +1516,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
'resourceDescription' => 'Popo',
'section' => 'Popo',
],
Expand Down Expand Up @@ -1538,6 +1546,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
'resourceDescription' => 'Popo',
'section' => 'Popo',
],
Expand All @@ -1558,6 +1567,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
'resourceDescription' => 'Popo',
'section' => 'Popo',
],
Expand Down Expand Up @@ -1586,6 +1596,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
'resourceDescription' => 'Popo',
'section' => 'Popo',
],
Expand Down Expand Up @@ -1622,6 +1633,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
'resourceDescription' => 'Popo',
'section' => 'Popo',
],
Expand Down Expand Up @@ -1889,6 +1901,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
13 => [
'method' => 'GET',
Expand All @@ -1915,6 +1928,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
14 => [
'method' => 'ANY',
Expand All @@ -1924,6 +1938,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
15 => [
'method' => 'ANY',
Expand All @@ -1940,6 +1955,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
16 => [
'method' => 'GET',
Expand All @@ -1949,6 +1965,7 @@
'authenticationRoles' => [
],
'deprecated' => true,
'scope' => null,
],
17 => [
'method' => 'POST',
Expand All @@ -1968,6 +1985,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
18 => [
'method' => 'GET',
Expand All @@ -1984,6 +2002,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
19 => [
'method' => 'GET',
Expand All @@ -1999,6 +2018,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
20 => [
'method' => 'GET',
Expand Down Expand Up @@ -2034,6 +2054,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
22 => [
'method' => 'ANY',
Expand Down Expand Up @@ -2135,6 +2156,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
23 => [
'method' => 'ANY',
Expand Down Expand Up @@ -2182,6 +2204,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
24 => [
'method' => 'ANY',
Expand Down Expand Up @@ -2283,6 +2306,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
25 => [
'method' => 'POST',
Expand All @@ -2292,6 +2316,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
26 => [
'method' => 'POST',
Expand All @@ -2301,6 +2326,7 @@
'authenticationRoles' => [
],
'deprecated' => false,
'scope' => null,
],
27 => [
'authentication' => false,
Expand All @@ -2309,6 +2335,7 @@
'https' => false,
'authenticationRoles' => [],
'deprecated' => false,
'scope' => null,
'requirements' => [
'_format' => [
'requirement' => '',
Expand Down
Loading

0 comments on commit d761d89

Please sign in to comment.