-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenAPI.php
More file actions
executable file
·64 lines (48 loc) · 1.44 KB
/
OpenAPI.php
File metadata and controls
executable file
·64 lines (48 loc) · 1.44 KB
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
<?php
declare(strict_types=1);
namespace Astral\Serialize\OpenApi\Storage\OpenAPI;
use Astral\Serialize\OpenApi\Collections\OpenApiCollection;
use Astral\Serialize\OpenApi\Storage\OpenAPI\Method\MethodInterface;
use Astral\Serialize\OpenApi\Storage\StorageInterface;
class OpenAPI implements StorageInterface
{
public string $openapi = '3.1.1';
public ApiInfo $info;
/** @var ServersStorage[] */
public array $servers;
public string $host;
public string $basePath;
/** @var array<TagStorage> */
public array $tags = [];
/** @var array<string,MethodInterface> */
public array $paths = [];
public function withApiInfo(ApiInfo $apiInfo): self
{
$this->info = $apiInfo;
return $this;
}
public function withServers(array $servers): self
{
$this->servers = $servers;
return $this;
}
public function withTags(array $tags): self
{
$this->tags = $tags;
return $this;
}
public function addTag(TagStorage $tag): void
{
// $this->tags[$tag->name] = $tag;
}
public function withPaths(array $paths): self
{
$this->paths = $paths;
return $this;
}
public function addPath(OpenApiCollection $openApiCollection): self
{
$this->paths[$openApiCollection->route->route][strtolower($openApiCollection->route->method->name)] = $openApiCollection->build();
return $this;
}
}