Debian Codegraph @

vendor/zircote/swagger-php/src/Annotations/Flow.php

raw
1 <?php declare(strict_types=1);
2
3 /**
4 * @license Apache 2.0
5 */
6
7 namespace OpenApi\Annotations;
8
9 use OpenApi\Generator;
10
11 /**
12 * Configuration details for a supported OAuth flow.
13 *
14 * @see [OAuth Flow Object](https://spec.openapis.org/oas/v3.1.1.html#oauth-flow-object)
15 *
16 * @Annotation
17 */
18 class Flow extends AbstractAnnotation
19 {
20 /**
21 * The authorization url to be used for this flow.
22 *
23 * This must be in the form of an url.
24 *
25 * @var string
26 */
27 public $authorizationUrl = Generator::UNDEFINED;
28
29 /**
30 * The token URL to be used for this flow.
31 *
32 * This must be in the form of an url.
33 *
34 * @var string
35 */
36 public $tokenUrl = Generator::UNDEFINED;
37
38 /**
39 * The URL to be used for obtaining refresh tokens.
40 *
41 * This must be in the form of an url.
42 *
43 * @var string
44 */
45 public $refreshUrl = Generator::UNDEFINED;
46
47 /**
48 * Flow name.
49 *
50 * One of ['implicit', 'password', 'authorizationCode', 'clientCredentials'].
51 *
52 * @var 'authorizationCode'|'clientCredentials'|'implicit'|'password'
53 */
54 public $flow = Generator::UNDEFINED;
55
56 /**
57 * The available scopes for the OAuth2 security scheme.
58 *
59 * A map between the scope name and a short description for it.
60 *
61 * @var array
62 */
63 public $scopes = Generator::UNDEFINED;
64
65 /**
66 * @inheritdoc
67 */
68 public static $_required = ['scopes', 'flow'];
69
70 /**
71 * @inheritdoc
72 */
73 public static $_types = [
74 'flow' => ['implicit', 'password', 'authorizationCode', 'clientCredentials'],
75 'refreshUrl' => 'string',
76 'authorizationUrl' => 'string',
77 'tokenUrl' => 'string',
78 ];
79
80 /**
81 * @inheritdoc
82 */
83 public static $_parents = [
84 SecurityScheme::class,
85 ];
86
87 /**
88 * @inheritdoc
89 */
90 public static $_nested = [
91 Attachable::class => ['attachables'],
92 ];
93
94 public function jsonSerialize(): \stdClass
95 {
96 if ($this->scopes === []) {
97 $this->scopes = new \stdClass();
98 }
99
100 return parent::jsonSerialize();
101 }
102 }