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 PathItem extends ClassStructure { |
15
|
|
|
/** @var string */ |
16
|
|
|
public $ref; |
17
|
|
|
|
18
|
|
|
/** @var Operation */ |
19
|
|
|
public $get; |
20
|
|
|
|
21
|
|
|
/** @var Operation */ |
22
|
|
|
public $put; |
23
|
|
|
|
24
|
|
|
/** @var Operation */ |
25
|
|
|
public $post; |
26
|
|
|
|
27
|
|
|
/** @var Operation */ |
28
|
|
|
public $delete; |
29
|
|
|
|
30
|
|
|
/** @var Operation */ |
31
|
|
|
public $options; |
32
|
|
|
|
33
|
|
|
/** @var Operation */ |
34
|
|
|
public $head; |
35
|
|
|
|
36
|
|
|
/** @var Operation */ |
37
|
|
|
public $patch; |
38
|
|
|
|
39
|
|
|
/** @var BodyParameter[]|HeaderParameterSubSchema[]|FormDataParameterSubSchema[]|QueryParameterSubSchema[]|PathParameterSubSchema[]|JsonReference[]|array The parameters needed to send a valid API call. */ |
40
|
|
|
public $parameters; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param Properties|static $properties |
44
|
|
|
* @param Schema $ownerSchema |
45
|
|
|
*/ |
46
|
|
|
public static function setUpProperties($properties, Schema $ownerSchema) |
47
|
|
|
{ |
48
|
|
|
$properties->ref = Schema::string(); |
49
|
|
|
$ownerSchema->addPropertyMapping('$ref', self::names()->ref); |
|
|
|
|
50
|
|
|
$properties->get = Operation::schema(); |
51
|
|
|
$properties->put = Operation::schema(); |
52
|
|
|
$properties->post = Operation::schema(); |
53
|
|
|
$properties->delete = Operation::schema(); |
54
|
|
|
$properties->options = Operation::schema(); |
55
|
|
|
$properties->head = Operation::schema(); |
56
|
|
|
$properties->patch = Operation::schema(); |
57
|
|
|
$properties->parameters = Schema::arr(); |
58
|
|
|
$properties->parameters->items = new Schema(); |
59
|
|
|
$properties->parameters->items->oneOf[0] = new Schema(); |
60
|
|
|
$properties->parameters->items->oneOf[0]->oneOf[0] = BodyParameter::schema(); |
61
|
|
|
$properties->parameters->items->oneOf[0]->oneOf[1] = Schema::object(); |
62
|
|
|
$properties->parameters->items->oneOf[0]->oneOf[1]->oneOf[0] = HeaderParameterSubSchema::schema(); |
63
|
|
|
$properties->parameters->items->oneOf[0]->oneOf[1]->oneOf[1] = FormDataParameterSubSchema::schema(); |
64
|
|
|
$properties->parameters->items->oneOf[0]->oneOf[1]->oneOf[2] = QueryParameterSubSchema::schema(); |
65
|
|
|
$properties->parameters->items->oneOf[0]->oneOf[1]->oneOf[3] = PathParameterSubSchema::schema(); |
66
|
|
|
$properties->parameters->items->oneOf[0]->oneOf[1]->required = array ( |
67
|
|
|
0 => 'name', |
68
|
|
|
1 => 'in', |
69
|
|
|
2 => 'type', |
70
|
|
|
); |
71
|
|
|
$properties->parameters->items->oneOf[1] = JsonReference::schema(); |
72
|
|
|
$properties->parameters->description = 'The parameters needed to send a valid API call.'; |
|
|
|
|
73
|
|
|
$properties->parameters->uniqueItems = true; |
74
|
|
|
$ownerSchema->type = 'object'; |
|
|
|
|
75
|
|
|
$ownerSchema->additionalProperties = false; |
76
|
|
|
$ownerSchema->patternProperties['^x-'] = new Schema(); |
77
|
|
|
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
|
|
|
|
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
|
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: