apie-lib /
openapi-schema
| 1 | <?php |
||
| 2 | |||
| 3 | |||
| 4 | namespace Apie\OpenapiSchema\Spec; |
||
| 5 | |||
| 6 | use Apie\CommonValueObjects\JavascriptRegularExpression; |
||
| 7 | use Apie\CompositeValueObjects\Exceptions\FieldMissingException; |
||
| 8 | use Apie\CompositeValueObjects\Exceptions\IgnoredKeysException; |
||
| 9 | use Apie\CompositeValueObjects\ValueObjects\StringList; |
||
| 10 | use Apie\OpenapiSchema\Concerns\CompositeValueObjectWithExtension; |
||
| 11 | use Apie\OpenapiSchema\Contract\SchemaContract; |
||
| 12 | use Apie\OpenapiSchema\Map\SchemaList; |
||
| 13 | use Apie\OpenapiSchema\Map\SchemaMap; |
||
| 14 | use Apie\OpenapiSchema\ValueObjects\SchemaTypes; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @see https://swagger.io/specification/#schema-object |
||
| 18 | */ |
||
| 19 | class Schema implements SchemaContract |
||
| 20 | { |
||
| 21 | use CompositeValueObjectWithExtension; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 22 | |||
| 23 | private function __construct() |
||
| 24 | { |
||
| 25 | } |
||
| 26 | |||
| 27 | protected function validateProperties(): void |
||
| 28 | { |
||
| 29 | if ($this->type) { |
||
| 30 | foreach ($this->type->getRequiredFields() as $requiredField) { |
||
| 31 | if ($this->$requiredField === null) { |
||
| 32 | throw new FieldMissingException($requiredField, $this); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | $ignoredKeys = []; |
||
| 36 | foreach ($this->type->getConflictedFields() as $conflictedField) { |
||
| 37 | if ($this->$conflictedField !== null) { |
||
| 38 | $ignoredKeys[] = $conflictedField; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | if ($ignoredKeys) { |
||
| 42 | throw new IgnoredKeysException($ignoredKeys, $this->type->getRequiredFields()); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var SchemaTypes|null |
||
| 49 | */ |
||
| 50 | private $type; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var string|null |
||
| 54 | */ |
||
| 55 | private $title; |
||
| 56 | /** |
||
| 57 | * @var float|int|null |
||
| 58 | */ |
||
| 59 | private $multipleOf; |
||
| 60 | /** |
||
| 61 | * @var float|int|null |
||
| 62 | */ |
||
| 63 | private $maximum; |
||
| 64 | /** |
||
| 65 | * @var float|int|bool|null |
||
| 66 | */ |
||
| 67 | private $exclusiveMaximum; |
||
| 68 | /** |
||
| 69 | * @var float|int|null |
||
| 70 | */ |
||
| 71 | private $minimum; |
||
| 72 | /** |
||
| 73 | * @var float|int|bool|null |
||
| 74 | */ |
||
| 75 | private $exclusiveMinimum; |
||
| 76 | /** |
||
| 77 | * @var int|null |
||
| 78 | */ |
||
| 79 | private $maxLength; |
||
| 80 | /** |
||
| 81 | * @var int|null |
||
| 82 | */ |
||
| 83 | private $minLength; |
||
| 84 | /** |
||
| 85 | * @var JavascriptRegularExpression|null |
||
| 86 | */ |
||
| 87 | private $pattern; |
||
| 88 | /** |
||
| 89 | * @var int|null |
||
| 90 | */ |
||
| 91 | private $maxItems; |
||
| 92 | /** |
||
| 93 | * @var int|null |
||
| 94 | */ |
||
| 95 | private $minItems; |
||
| 96 | /** |
||
| 97 | * @var bool|null |
||
| 98 | */ |
||
| 99 | private $uniqueItems; |
||
| 100 | /** |
||
| 101 | * @var int|null |
||
| 102 | */ |
||
| 103 | private $maxProperties; |
||
| 104 | /** |
||
| 105 | * @var int|null |
||
| 106 | */ |
||
| 107 | private $minProperties; |
||
| 108 | /** |
||
| 109 | * @var StringList|null |
||
| 110 | */ |
||
| 111 | private $required; |
||
| 112 | /** |
||
| 113 | * @var array|null |
||
| 114 | */ |
||
| 115 | private $enum; |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @var SchemaList|null |
||
| 119 | */ |
||
| 120 | private $allOf; |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @var SchemaList|null |
||
| 124 | */ |
||
| 125 | private $anyOf; |
||
| 126 | |||
| 127 | /** |
||
| 128 | * @var SchemaList|null |
||
| 129 | */ |
||
| 130 | private $oneOf; |
||
| 131 | |||
| 132 | /** |
||
| 133 | * @var SchemaList|null |
||
| 134 | */ |
||
| 135 | private $not; |
||
| 136 | |||
| 137 | /** |
||
| 138 | * @var SchemaContract|Schema|Reference|null |
||
| 139 | */ |
||
| 140 | private $items; |
||
| 141 | |||
| 142 | /** |
||
| 143 | * @var bool|SchemaContract|Schema|Reference|null |
||
| 144 | */ |
||
| 145 | private $additionalProperties; |
||
| 146 | |||
| 147 | /** |
||
| 148 | * @var SchemaMap|null |
||
| 149 | */ |
||
| 150 | private $properties; |
||
| 151 | |||
| 152 | /** |
||
| 153 | * @var string|null |
||
| 154 | */ |
||
| 155 | private $description; |
||
| 156 | |||
| 157 | /** |
||
| 158 | * @var string|null |
||
| 159 | */ |
||
| 160 | private $format; |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @var mixed|null |
||
| 164 | */ |
||
| 165 | private $default; |
||
| 166 | |||
| 167 | /** |
||
| 168 | * @var bool|null |
||
| 169 | */ |
||
| 170 | private $nullable; |
||
| 171 | /** |
||
| 172 | * @var Discriminator|null |
||
| 173 | */ |
||
| 174 | private $discriminator; |
||
| 175 | |||
| 176 | /** |
||
| 177 | * @var bool|null |
||
| 178 | */ |
||
| 179 | private $readOnly; |
||
| 180 | |||
| 181 | /** |
||
| 182 | * @var bool|null |
||
| 183 | */ |
||
| 184 | private $writeOnly; |
||
| 185 | |||
| 186 | /** |
||
| 187 | * @var Xml|null |
||
| 188 | */ |
||
| 189 | private $xml; |
||
| 190 | |||
| 191 | /** |
||
| 192 | * @var ExternalDocs|null |
||
| 193 | */ |
||
| 194 | private $externalDocs; |
||
| 195 | |||
| 196 | /** |
||
| 197 | * @var mixed|null |
||
| 198 | */ |
||
| 199 | private $example; |
||
| 200 | |||
| 201 | /** |
||
| 202 | * @var bool|null |
||
| 203 | */ |
||
| 204 | private $deprecated; |
||
| 205 | } |
||
| 206 |