1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace erasys\OpenApi\Spec\v3; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* This is the root document object of the OpenAPI document. |
7
|
|
|
* |
8
|
|
|
* @see https://swagger.io/specification/ |
9
|
|
|
*/ |
10
|
|
|
class Document extends AbstractObject implements ExtensibleInterface |
11
|
|
|
{ |
12
|
|
|
const DEFAULT_OPENAPI_VERSION = '3.0.1'; |
13
|
|
|
const SCHEME_HTTP = 'http'; |
14
|
|
|
const SCHEME_HTTPS = 'https'; |
15
|
|
|
const SCHEME_WEBSOCKET = 'ws'; |
16
|
|
|
const SCHEME_SECURE_WEBSOCKET = 'wss'; |
17
|
|
|
const MIME_TYPE_JSON = 'application/json'; |
18
|
|
|
const MIME_TYPE_JSON_SCHEMA = 'application/schema+json'; |
19
|
|
|
const MIME_TYPE_URLENCODED = 'application/x-www-form-urlencoded'; |
20
|
|
|
const MIME_TYPE_MULTIPART = 'multipart/form-data'; |
21
|
|
|
const PARAM_IN_PATH = 'path'; |
22
|
|
|
const PARAM_IN_QUERY = 'query'; |
23
|
|
|
const PARAM_IN_HEADER = 'header'; |
24
|
|
|
const PARAM_IN_COOKIE = 'cookie'; |
25
|
|
|
const PARAM_STYLE_MATRIX = 'matrix'; |
26
|
|
|
const PARAM_STYLE_LABEL = 'label'; |
27
|
|
|
const PARAM_STYLE_FORM = 'form'; |
28
|
|
|
const PARAM_STYLE_SIMPLE = 'simple'; |
29
|
|
|
const PARAM_STYLE_SPACE_DELIMITED = 'spaceDelimited'; |
30
|
|
|
const PARAM_STYLE_PIPE_DELIMITED = 'pipeDelimited'; |
31
|
|
|
const PARAM_STYLE_DEEP_OBJECT = 'deepObject'; |
32
|
|
|
const TYPE_STRING = 'string'; |
33
|
|
|
const TYPE_INTEGER = 'integer'; |
34
|
|
|
const TYPE_FLOAT = 'number'; |
35
|
|
|
const TYPE_DOUBLE = 'number'; |
36
|
|
|
const TYPE_NUMBER = 'number'; |
37
|
|
|
const TYPE_BOOLEAN = 'boolean'; |
38
|
|
|
const TYPE_ARRAY = 'array'; |
39
|
|
|
const TYPE_OBJECT = 'object'; |
40
|
|
|
const TYPE_NULL = 'null'; |
41
|
|
|
const TYPE_FORMAT_STRING_INT32 = 'int32'; |
42
|
|
|
const TYPE_FORMAT_STRING_INT64 = 'int64'; |
43
|
|
|
const TYPE_FORMAT_STRING_BYTE = 'byte'; |
44
|
|
|
const TYPE_FORMAT_STRING_BINARY = 'binary'; |
45
|
|
|
const TYPE_FORMAT_STRING_DATE = 'date'; |
46
|
|
|
const TYPE_FORMAT_STRING_DATETIME = 'date-time'; |
47
|
|
|
const TYPE_FORMAT_STRING_PASSWORD = 'password'; |
48
|
|
|
const TYPE_FORMAT_NUMBER_FLOAT = 'float'; |
49
|
|
|
const TYPE_FORMAT_NUMBER_DOUBLE = 'double'; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* REQUIRED. This string MUST be the semantic version number of the OpenAPI Specification version that the |
53
|
|
|
* OpenAPI document uses. The openapi field SHOULD be used by tooling specifications and clients |
54
|
|
|
* to interpret the OpenAPI document. This is not related to the API info.version string. |
55
|
|
|
* |
56
|
|
|
* |
57
|
|
|
* @var string |
58
|
|
|
*/ |
59
|
|
|
public $openapi = self::DEFAULT_OPENAPI_VERSION; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required. |
63
|
|
|
* |
64
|
|
|
* |
65
|
|
|
* @var Info |
66
|
|
|
*/ |
67
|
|
|
public $info; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* REQUIRED. The available paths and operations for the API. |
71
|
|
|
* A map between a path and its definition. |
72
|
|
|
* |
73
|
|
|
* The key is the relative path to an individual endpoint. The path MUST begin with a slash. |
74
|
|
|
* The path is appended (no relative URL resolution) to the expanded URL from the Server Object's url |
75
|
|
|
* field in order to construct the full URL. Path templating is allowed. |
76
|
|
|
* |
77
|
|
|
* When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. |
78
|
|
|
* Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical. |
79
|
|
|
* In case of ambiguous matching, it's up to the tooling to decide which one to use. |
80
|
|
|
* |
81
|
|
|
* @see https://swagger.io/specification/#pathsObject |
82
|
|
|
* @see https://swagger.io/specification/#pathTemplating |
83
|
|
|
* |
84
|
|
|
* |
85
|
|
|
* @var PathItem[] array<string, Path> |
86
|
|
|
*/ |
87
|
|
|
public $paths; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* An array of Server Objects, which provide connectivity information to a target server. |
91
|
|
|
* If the servers property is not provided, or is an empty array, |
92
|
|
|
* the default value would be a Server Object with a url value of /. |
93
|
|
|
* |
94
|
|
|
* @var Server[] |
95
|
|
|
*/ |
96
|
|
|
public $servers; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* An element to hold various schemas for the specification. |
100
|
|
|
* |
101
|
|
|
* @var Components |
102
|
|
|
*/ |
103
|
|
|
public $components; |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* A declaration of which security mechanisms can be used across the API. |
107
|
|
|
* The list of values includes alternative security requirement objects that can be used. |
108
|
|
|
* Only one of the security requirement objects need to be satisfied to authorize a request. |
109
|
|
|
* Individual operations can override this definition. |
110
|
|
|
* |
111
|
|
|
* @example {"api_key": []} |
112
|
|
|
* |
113
|
|
|
* @see https://swagger.io/specification/#securityRequirementObject |
114
|
|
|
* @var string[] array<string, string[]> |
115
|
|
|
*/ |
116
|
|
|
public $security; |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* A list of tags used by the specification with additional metadata. |
120
|
|
|
* The order of the tags can be used to reflect on their order by the parsing tools. |
121
|
|
|
* Not all tags that are used by the Operation Object must be declared. |
122
|
|
|
* The tags that are not declared MAY be organized randomly or based on the tools' logic. |
123
|
|
|
* Each tag name in the list MUST be unique. |
124
|
|
|
* |
125
|
|
|
* @var Tag[] |
126
|
|
|
*/ |
127
|
|
|
public $tags; |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Additional external documentation. |
131
|
|
|
* |
132
|
|
|
* @var ExternalDocumentation |
133
|
|
|
*/ |
134
|
|
|
public $externalDocs; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param Info $info |
138
|
|
|
* @param PathItem[] $paths |
139
|
|
|
* @param string $openapi |
140
|
|
|
* @param array $additionalProperties |
141
|
|
|
*/ |
142
|
12 |
|
public function __construct(Info $info, array $paths, string $openapi = '3.0.1', array $additionalProperties = []) |
143
|
|
|
{ |
144
|
12 |
|
parent::__construct($additionalProperties); |
145
|
|
|
|
146
|
12 |
|
$this->info = $info; |
147
|
12 |
|
$this->paths = $paths; |
148
|
12 |
|
$this->openapi = $openapi; |
149
|
12 |
|
} |
150
|
|
|
} |
151
|
|
|
|