1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @file ATTENTION!!! The code below was carefully crafted by a mean machine. |
4
|
|
|
* Please consider to NOT put any emotional human-generated modifications as AI will throw them away with no mercy. |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Swaggest\JsonSchema\SwaggerSchema; |
8
|
|
|
|
9
|
|
|
use Swaggest\JsonSchema\Constraint\Properties; |
10
|
|
|
use Swaggest\JsonSchema\Schema; |
|
|
|
|
11
|
|
|
use Swaggest\JsonSchema\Structure\ClassStructure; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
class Oauth2AccessCodeSecurity extends ClassStructure { |
15
|
|
|
/** @var string */ |
16
|
|
|
public $type; |
17
|
|
|
|
18
|
|
|
/** @var string */ |
19
|
|
|
public $flow; |
20
|
|
|
|
21
|
|
|
/** @var string[] */ |
22
|
|
|
public $scopes; |
23
|
|
|
|
24
|
|
|
/** @var string */ |
25
|
|
|
public $authorizationUrl; |
26
|
|
|
|
27
|
|
|
/** @var string */ |
28
|
|
|
public $tokenUrl; |
29
|
|
|
|
30
|
|
|
/** @var string */ |
31
|
|
|
public $description; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param Properties|static $properties |
35
|
|
|
* @param Schema $ownerSchema |
36
|
|
|
*/ |
37
|
|
|
public static function setUpProperties($properties, Schema $ownerSchema) |
38
|
|
|
{ |
39
|
|
|
$properties->type = Schema::string(); |
40
|
|
|
$properties->type->enum = array ( |
41
|
|
|
0 => 'oauth2', |
42
|
|
|
); |
43
|
|
|
$properties->flow = Schema::string(); |
44
|
|
|
$properties->flow->enum = array ( |
45
|
|
|
0 => 'accessCode', |
46
|
|
|
); |
47
|
|
|
$properties->scopes = Schema::object(); |
48
|
|
|
$properties->scopes->additionalProperties = Schema::string(); |
49
|
|
|
$properties->authorizationUrl = Schema::string(); |
50
|
|
|
$properties->authorizationUrl->format = 'uri'; |
51
|
|
|
$properties->tokenUrl = Schema::string(); |
52
|
|
|
$properties->tokenUrl->format = 'uri'; |
53
|
|
|
$properties->description = Schema::string(); |
54
|
|
|
$ownerSchema->type = 'object'; |
|
|
|
|
55
|
|
|
$ownerSchema->additionalProperties = false; |
56
|
|
|
$ownerSchema->patternProperties['^x-'] = new Schema(); |
57
|
|
|
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
|
|
|
|
58
|
|
|
$ownerSchema->required = array ( |
59
|
|
|
0 => 'type', |
60
|
|
|
1 => 'flow', |
61
|
|
|
2 => 'authorizationUrl', |
62
|
|
|
3 => 'tokenUrl', |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: