1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the API Platform project. |
5
|
|
|
* |
6
|
|
|
* (c) Kévin Dunglas <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace ApiPlatform\Core\OpenApi; |
15
|
|
|
|
16
|
|
|
use ApiPlatform\Core\JsonSchema\Schema as JsonSchema; |
17
|
|
|
|
18
|
|
|
class Schema |
19
|
|
|
{ |
20
|
|
|
private $nullable; |
21
|
|
|
private $discriminator; |
22
|
|
|
private $readOnly; |
23
|
|
|
private $writeOnly; |
24
|
|
|
private $xml; |
25
|
|
|
private $externalDocs; |
26
|
|
|
private $example; |
27
|
|
|
private $deprecated; |
28
|
|
|
|
29
|
|
|
public function __construct(?bool $nullable = false, $discriminator = null, bool $readOnly = false, bool $writeOnly = false, string $xml = null, $externalDocs = null, $example = null, bool $deprecated = false) |
30
|
|
|
{ |
31
|
|
|
$this->nullable = $nullable; |
32
|
|
|
$this->discriminator = $discriminator; |
33
|
|
|
$this->readOnly = $readOnly; |
34
|
|
|
$this->writeOnly = $writeOnly; |
35
|
|
|
$this->xml = $xml; |
36
|
|
|
$this->externalDocs = $externalDocs; |
37
|
|
|
$this->example = $example; |
38
|
|
|
$this->deprecated = $deprecated; |
39
|
|
|
$this->schema = new JsonSchema(); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function setDefinitions(array $definitions) |
43
|
|
|
{ |
44
|
|
|
$this->schema->setDefinitions(new \ArrayObject($definitions)); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function getDefinitions(): \ArrayObject |
48
|
|
|
{ |
49
|
|
|
return new \ArrayObject(array_merge((array) $this->schema->getDefinitions(), (array) $this)); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function getNullable() |
53
|
|
|
{ |
54
|
|
|
return $this->nullable; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getDiscriminator() |
58
|
|
|
{ |
59
|
|
|
return $this->discriminator; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getReadOnly() |
63
|
|
|
{ |
64
|
|
|
return $this->readOnly; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function getWriteOnly() |
68
|
|
|
{ |
69
|
|
|
return $this->writeOnly; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getXml() |
73
|
|
|
{ |
74
|
|
|
return $this->xml; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getExternalDocs() |
78
|
|
|
{ |
79
|
|
|
return $this->externalDocs; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getExample() |
83
|
|
|
{ |
84
|
|
|
return $this->example; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function getDeprecated() |
88
|
|
|
{ |
89
|
|
|
return $this->deprecated; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|