Support oauth2 scopes in Security annotation

This commit is contained in:
Paul des Garets 2021-01-26 19:05:27 +01:00
parent 306aba97a4
commit eeb0b4efba
4 changed files with 9 additions and 1 deletions

View File

@ -21,6 +21,7 @@ class Security extends AbstractAnnotation
/** {@inheritdoc} */
public static $_types = [
'name' => 'string',
'scopes' => '[string]',
];
public static $_required = ['name'];
@ -29,4 +30,9 @@ class Security extends AbstractAnnotation
* @var string
*/
public $name;
/**
* @var string[]
*/
public $scopes = [];
}

View File

@ -102,7 +102,7 @@ final class OpenApiPhpDescriber
if ($annotation instanceof Security) {
$annotation->validate();
$mergeProperties->security[] = [$annotation->name => []];
$mergeProperties->security[] = [$annotation->name => $annotation->scopes];
continue;
}

View File

@ -160,6 +160,7 @@ class ApiController
* @OA\Response(response="201", description="")
* @Security(name="api_key")
* @Security(name="basic")
* @Security(name="oauth2", scopes={"scope_1"})
*/
public function securityAction()
{

View File

@ -338,6 +338,7 @@ class FunctionalTest extends WebTestCase
$expected = [
['api_key' => []],
['basic' => []],
['oauth2' => ['scope_1']],
];
$this->assertEquals($expected, $operation->security);
}