mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Support oauth2 scopes in Security annotation
This commit is contained in:
parent
306aba97a4
commit
eeb0b4efba
@ -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 = [];
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ final class OpenApiPhpDescriber
|
||||
|
||||
if ($annotation instanceof Security) {
|
||||
$annotation->validate();
|
||||
$mergeProperties->security[] = [$annotation->name => []];
|
||||
$mergeProperties->security[] = [$annotation->name => $annotation->scopes];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -338,6 +338,7 @@ class FunctionalTest extends WebTestCase
|
||||
$expected = [
|
||||
['api_key' => []],
|
||||
['basic' => []],
|
||||
['oauth2' => ['scope_1']],
|
||||
];
|
||||
$this->assertEquals($expected, $operation->security);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user