|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Aweapi\Openapi\Builders; |
|
6
|
|
|
|
|
7
|
|
|
use Aweapi\Openapi\Objects; |
|
8
|
|
|
|
|
9
|
|
|
final class OperationBuilder implements Objects\OperationFactory |
|
10
|
|
|
{ |
|
11
|
|
|
use Properties\OptionalExtensions; |
|
12
|
|
|
|
|
13
|
|
|
private $callbacks; |
|
14
|
|
|
|
|
15
|
|
|
private $deprecated = false; |
|
16
|
|
|
|
|
17
|
|
|
private $description; |
|
18
|
|
|
|
|
19
|
|
|
private $externalDocs; |
|
20
|
|
|
|
|
21
|
|
|
private $operationId; |
|
22
|
|
|
|
|
23
|
|
|
private $parameters; |
|
24
|
|
|
|
|
25
|
|
|
private $requestBody; |
|
26
|
|
|
|
|
27
|
|
|
private $responses; |
|
28
|
|
|
|
|
29
|
|
|
private $security; |
|
30
|
|
|
|
|
31
|
|
|
private $servers; |
|
32
|
|
|
|
|
33
|
|
|
private $summary; |
|
34
|
|
|
|
|
35
|
|
|
private $tags = []; |
|
36
|
|
|
|
|
37
|
3 |
|
public function createOperation(): Objects\Operation |
|
38
|
|
|
{ |
|
39
|
3 |
|
return new Objects\Operation( |
|
40
|
3 |
|
$this->getResponses()->createOperationResponses(), |
|
41
|
3 |
|
$this->getRequestBody() ? $this->getRequestBody()->createRequestBody() : null, |
|
42
|
3 |
|
$this->getTags(), |
|
43
|
3 |
|
$this->getOperationId(), |
|
44
|
3 |
|
$this->getSummary(), |
|
45
|
3 |
|
$this->getDescription(), |
|
46
|
3 |
|
$this->isDeprecated(), |
|
47
|
3 |
|
$this->getParameters() ? $this->getParameters()->createParameterCollection() : null, |
|
48
|
3 |
|
$this->getSecurity() ? $this->getSecurity()->createSecurityRequirementCollection() : null, |
|
49
|
3 |
|
$this->getCallbacks() ? $this->getCallbacks()->createCallbackRequests() : null, |
|
50
|
3 |
|
$this->getServers() ? $this->getServers()->createServerCollection() : null, |
|
51
|
3 |
|
$this->getExternalDocs() ? $this->getExternalDocs()->createExternalDocumentation() : null, |
|
52
|
3 |
|
$this->getExtensions() |
|
53
|
|
|
); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function setCallbacks(Objects\CallbackRequestsFactory $callbacks): self |
|
57
|
|
|
{ |
|
58
|
|
|
$this->callbacks = $callbacks; |
|
59
|
|
|
|
|
60
|
|
|
return $this; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
1 |
|
public function setDeprecated(bool $deprecated): self |
|
64
|
|
|
{ |
|
65
|
1 |
|
$this->deprecated = $deprecated; |
|
66
|
|
|
|
|
67
|
1 |
|
return $this; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
1 |
|
public function setDescription(string $description): self |
|
71
|
|
|
{ |
|
72
|
1 |
|
$this->description = $description; |
|
73
|
|
|
|
|
74
|
1 |
|
return $this; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
1 |
|
public function setExternalDocs(Objects\ExternalDocumentationFactory $externalDocs): self |
|
78
|
|
|
{ |
|
79
|
1 |
|
$this->externalDocs = $externalDocs; |
|
80
|
|
|
|
|
81
|
1 |
|
return $this; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
1 |
|
public function setOperationId(string $operationId): self |
|
85
|
|
|
{ |
|
86
|
1 |
|
$this->operationId = $operationId; |
|
87
|
|
|
|
|
88
|
1 |
|
return $this; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
1 |
|
public function setParameters(Objects\ParameterCollectionFactory $parameters): self |
|
92
|
|
|
{ |
|
93
|
1 |
|
$this->parameters = $parameters; |
|
94
|
|
|
|
|
95
|
1 |
|
return $this; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
1 |
|
public function setRequestBody(Objects\RequestBodyFactory $requestBody): self |
|
99
|
|
|
{ |
|
100
|
1 |
|
$this->requestBody = $requestBody; |
|
101
|
|
|
|
|
102
|
1 |
|
return $this; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
3 |
|
public function setResponses(Objects\OperationResponsesFactory $responses): self |
|
106
|
|
|
{ |
|
107
|
3 |
|
$this->responses = $responses; |
|
108
|
|
|
|
|
109
|
3 |
|
return $this; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
1 |
|
public function setSecurity(Objects\SecurityRequirementCollectionFactory $security): self |
|
113
|
|
|
{ |
|
114
|
1 |
|
$this->security = $security; |
|
115
|
|
|
|
|
116
|
1 |
|
return $this; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
1 |
|
public function setServers(Objects\ServerCollectionFactory $servers): self |
|
120
|
|
|
{ |
|
121
|
1 |
|
$this->servers = $servers; |
|
122
|
|
|
|
|
123
|
1 |
|
return $this; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
1 |
|
public function setSummary(string $summary): self |
|
127
|
|
|
{ |
|
128
|
1 |
|
$this->summary = $summary; |
|
129
|
|
|
|
|
130
|
1 |
|
return $this; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
1 |
|
public function setTags(array $tags): self |
|
134
|
|
|
{ |
|
135
|
1 |
|
$this->tags = $tags; |
|
136
|
|
|
|
|
137
|
1 |
|
return $this; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
3 |
|
private function getCallbacks(): ?Objects\CallbackRequestsFactory |
|
141
|
|
|
{ |
|
142
|
3 |
|
return $this->callbacks; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
3 |
|
private function getDescription(): ?string |
|
146
|
|
|
{ |
|
147
|
3 |
|
return $this->description; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
3 |
|
private function getExternalDocs(): ?Objects\ExternalDocumentationFactory |
|
151
|
|
|
{ |
|
152
|
3 |
|
return $this->externalDocs; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
3 |
|
private function getOperationId(): ?string |
|
156
|
|
|
{ |
|
157
|
3 |
|
return $this->operationId; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
3 |
|
private function getParameters(): ?Objects\ParameterCollectionFactory |
|
161
|
|
|
{ |
|
162
|
3 |
|
return $this->parameters; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
3 |
|
private function getRequestBody(): ?Objects\RequestBodyFactory |
|
166
|
|
|
{ |
|
167
|
3 |
|
return $this->requestBody; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
3 |
|
private function getResponses(): Objects\OperationResponsesFactory |
|
171
|
|
|
{ |
|
172
|
3 |
|
return $this->responses; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
3 |
|
private function getSecurity(): ?Objects\SecurityRequirementCollectionFactory |
|
176
|
|
|
{ |
|
177
|
3 |
|
return $this->security; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
3 |
|
private function getServers(): ?Objects\ServerCollectionFactory |
|
181
|
|
|
{ |
|
182
|
3 |
|
return $this->servers; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
3 |
|
private function getSummary(): ?string |
|
186
|
|
|
{ |
|
187
|
3 |
|
return $this->summary; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
3 |
|
private function getTags(): array |
|
191
|
|
|
{ |
|
192
|
3 |
|
return $this->tags; |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
3 |
|
private function isDeprecated(): bool |
|
196
|
|
|
{ |
|
197
|
3 |
|
return $this->deprecated; |
|
198
|
|
|
} |
|
199
|
|
|
} |
|
200
|
|
|
|