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 the splendid 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 as JsonBasicSchema; |
11
|
|
|
use Swaggest\JsonSchema\Structure\ClassStructure; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
class FileSchema extends ClassStructure { |
15
|
|
|
/** @var string */ |
16
|
|
|
public $format; |
17
|
|
|
|
18
|
|
|
/** @var string */ |
19
|
|
|
public $title; |
20
|
|
|
|
21
|
|
|
/** @var string */ |
22
|
|
|
public $description; |
23
|
|
|
|
24
|
|
|
public $default; |
25
|
|
|
|
26
|
|
|
/** @var string[]|array */ |
27
|
|
|
public $required; |
28
|
|
|
|
29
|
|
|
/** @var string */ |
30
|
|
|
public $type; |
31
|
|
|
|
32
|
|
|
/** @var bool */ |
33
|
|
|
public $readOnly; |
34
|
|
|
|
35
|
|
|
/** @var ExternalDocs information about external documentation */ |
36
|
|
|
public $externalDocs; |
37
|
|
|
|
38
|
|
|
public $example; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param Properties|static $properties |
42
|
|
|
* @param JsonBasicSchema $ownerSchema |
43
|
|
|
*/ |
44
|
|
|
public static function setUpProperties($properties, JsonBasicSchema $ownerSchema) |
45
|
|
|
{ |
46
|
|
|
$properties->format = JsonBasicSchema::string(); |
47
|
|
|
$properties->title = JsonBasicSchema::string(); |
48
|
|
|
$properties->description = JsonBasicSchema::string(); |
49
|
|
|
$properties->default = new JsonBasicSchema(); |
50
|
|
|
$properties->required = JsonBasicSchema::arr(); |
51
|
|
|
$properties->required->items = JsonBasicSchema::string(); |
52
|
|
|
$properties->required->minItems = 1; |
53
|
|
|
$properties->required->uniqueItems = true; |
54
|
|
|
$properties->type = JsonBasicSchema::string(); |
55
|
|
|
$properties->type->enum = array ( |
56
|
|
|
0 => 'file', |
57
|
|
|
); |
58
|
|
|
$properties->readOnly = JsonBasicSchema::boolean(); |
59
|
|
|
$properties->readOnly->default = false; |
60
|
|
|
$properties->externalDocs = ExternalDocs::schema(); |
61
|
|
|
$properties->example = new JsonBasicSchema(); |
62
|
|
|
$ownerSchema->type = 'object'; |
|
|
|
|
63
|
|
|
$ownerSchema->additionalProperties = false; |
64
|
|
|
$ownerSchema->patternProperties['^x-'] = new JsonBasicSchema(); |
65
|
|
|
$ownerSchema->patternProperties['^x-']->description = 'Any property starting with x- is valid.'; |
66
|
|
|
$ownerSchema->description = 'A deterministic version of a JSON Schema object.'; |
67
|
|
|
$ownerSchema->required = array ( |
68
|
|
|
0 => 'type', |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param string $format |
74
|
|
|
* @return $this |
75
|
|
|
*/ |
76
|
|
|
public function setFormat($format) |
77
|
|
|
{ |
78
|
|
|
$this->format = $format; |
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @param string $title |
84
|
|
|
* @return $this |
85
|
|
|
*/ |
86
|
|
|
public function setTitle($title) |
87
|
|
|
{ |
88
|
|
|
$this->title = $title; |
89
|
|
|
return $this; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param string $description |
94
|
|
|
* @return $this |
95
|
|
|
*/ |
96
|
|
|
public function setDescription($description) |
97
|
|
|
{ |
98
|
|
|
$this->description = $description; |
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param $default |
104
|
|
|
* @return $this |
105
|
|
|
*/ |
106
|
|
|
public function setDefault($default) |
107
|
|
|
{ |
108
|
|
|
$this->default = $default; |
109
|
|
|
return $this; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param string[]|array $required |
114
|
|
|
* @return $this |
115
|
|
|
*/ |
116
|
|
|
public function setRequired($required) |
117
|
|
|
{ |
118
|
|
|
$this->required = $required; |
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param string $type |
124
|
|
|
* @return $this |
125
|
|
|
*/ |
126
|
|
|
public function setType($type) |
127
|
|
|
{ |
128
|
|
|
$this->type = $type; |
129
|
|
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param bool $readOnly |
134
|
|
|
* @return $this |
135
|
|
|
*/ |
136
|
|
|
public function setReadOnly($readOnly) |
137
|
|
|
{ |
138
|
|
|
$this->readOnly = $readOnly; |
139
|
|
|
return $this; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param ExternalDocs $externalDocs information about external documentation |
144
|
|
|
* @return $this |
145
|
|
|
*/ |
146
|
|
|
public function setExternalDocs($externalDocs) |
147
|
|
|
{ |
148
|
|
|
$this->externalDocs = $externalDocs; |
149
|
|
|
return $this; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @param $example |
154
|
|
|
* @return $this |
155
|
|
|
*/ |
156
|
|
|
public function setExample($example) |
157
|
|
|
{ |
158
|
|
|
$this->example = $example; |
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..