mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +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} */
|
/** {@inheritdoc} */
|
||||||
public static $_types = [
|
public static $_types = [
|
||||||
'name' => 'string',
|
'name' => 'string',
|
||||||
|
'scopes' => '[string]',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static $_required = ['name'];
|
public static $_required = ['name'];
|
||||||
@ -29,4 +30,9 @@ class Security extends AbstractAnnotation
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $name;
|
public $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
public $scopes = [];
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ final class OpenApiPhpDescriber
|
|||||||
|
|
||||||
if ($annotation instanceof Security) {
|
if ($annotation instanceof Security) {
|
||||||
$annotation->validate();
|
$annotation->validate();
|
||||||
$mergeProperties->security[] = [$annotation->name => []];
|
$mergeProperties->security[] = [$annotation->name => $annotation->scopes];
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,7 @@ class ApiController
|
|||||||
* @OA\Response(response="201", description="")
|
* @OA\Response(response="201", description="")
|
||||||
* @Security(name="api_key")
|
* @Security(name="api_key")
|
||||||
* @Security(name="basic")
|
* @Security(name="basic")
|
||||||
|
* @Security(name="oauth2", scopes={"scope_1"})
|
||||||
*/
|
*/
|
||||||
public function securityAction()
|
public function securityAction()
|
||||||
{
|
{
|
||||||
|
@ -338,6 +338,7 @@ class FunctionalTest extends WebTestCase
|
|||||||
$expected = [
|
$expected = [
|
||||||
['api_key' => []],
|
['api_key' => []],
|
||||||
['basic' => []],
|
['basic' => []],
|
||||||
|
['oauth2' => ['scope_1']],
|
||||||
];
|
];
|
||||||
$this->assertEquals($expected, $operation->security);
|
$this->assertEquals($expected, $operation->security);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user