-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOpenApi.php
156 lines (120 loc) · 3.3 KB
/
OpenApi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace ApiPlatform\OpenApi;
use ApiPlatform\OpenApi\Model\Components;
use ApiPlatform\OpenApi\Model\ExtensionTrait;
use ApiPlatform\OpenApi\Model\Info;
use ApiPlatform\OpenApi\Model\Paths;
final class OpenApi
{
use ExtensionTrait;
// We're actually supporting 3.1 but swagger ui has a version constraint
// public const VERSION = '3.1.0';
public const VERSION = '3.0.0';
private string $openapi = self::VERSION;
public function __construct(private Info $info, private array $servers, private Paths $paths, private ?Components $components = null, private array $security = [], private array $tags = [], private $externalDocs = null, private ?string $jsonSchemaDialect = null, private readonly ?\ArrayObject $webhooks = null)
{
}
public function getOpenapi(): string
{
return $this->openapi;
}
public function getInfo(): Info
{
return $this->info;
}
public function getServers(): array
{
return $this->servers;
}
public function getPaths(): Paths
{
return $this->paths;
}
public function getComponents(): Components
{
return $this->components;
}
public function getSecurity(): array
{
return $this->security;
}
public function getTags(): array
{
return $this->tags;
}
public function getExternalDocs(): ?array
{
return $this->externalDocs;
}
public function getJsonSchemaDialect(): ?string
{
return $this->jsonSchemaDialect;
}
public function getWebhooks(): ?\ArrayObject
{
return $this->webhooks;
}
public function withOpenapi(string $openapi): self
{
$clone = clone $this;
$clone->openapi = $openapi;
return $clone;
}
public function withInfo(Info $info): self
{
$clone = clone $this;
$clone->info = $info;
return $clone;
}
public function withServers(array $servers): self
{
$clone = clone $this;
$clone->servers = $servers;
return $clone;
}
public function withPaths(Paths $paths): self
{
$clone = clone $this;
$clone->paths = $paths;
return $clone;
}
public function withComponents(Components $components): self
{
$clone = clone $this;
$clone->components = $components;
return $clone;
}
public function withSecurity(array $security): self
{
$clone = clone $this;
$clone->security = $security;
return $clone;
}
public function withTags(array $tags): self
{
$clone = clone $this;
$clone->tags = $tags;
return $clone;
}
public function withExternalDocs(array $externalDocs): self
{
$clone = clone $this;
$clone->externalDocs = $externalDocs;
return $clone;
}
public function withJsonSchemaDialect(?string $jsonSchemaDialect): self
{
$clone = clone $this;
$clone->jsonSchemaDialect = $jsonSchemaDialect;
return $clone;
}
}