Skip to content

Commit 06f986a

Browse files
committed
feat(openapi): support OpenAPI 3.2.0
Add the fields introduced by OpenAPI 3.2.0 to the model classes and bump the declared version from 3.1.0 to 3.2.0. - OpenApi: $self - Server: name - Tag: summary, parent, kind - PathItem: query (QUERY method), additionalOperations - MediaType: itemSchema, prefixEncoding, itemEncoding (streaming) - Encoding: encoding, prefixEncoding, itemEncoding - Response: summary - Example: dataValue, serializedValue - Components: mediaTypes - SecurityScheme: oauth2MetadataUrl, deprecated - OAuthFlows: deviceAuthorization - OAuthFlow: deviceAuthorizationUrl All additions are new constructor params at the end with null defaults; with SKIP_NULL_VALUES they never appear in output unless set. The 3.0.0 downgrade via ?spec_version=3.0.0 is unchanged.
1 parent 9b7ace5 commit 06f986a

15 files changed

Lines changed: 318 additions & 18 deletions

src/OpenApi/Model/Components.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ final class Components
3030
* @param \ArrayObject<string, Link>|\ArrayObject<string, Reference> $links
3131
* @param \ArrayObject<string, array<string, PathItem>>|\ArrayObject<string, array<string, Reference>> $callbacks
3232
* @param \ArrayObject<string, PathItem>|\ArrayObject<string, Reference> $pathItems
33+
* @param \ArrayObject<string, MediaType>|\ArrayObject<string, Reference> $mediaTypes
3334
*/
34-
public function __construct(?\ArrayObject $schemas = null, private ?\ArrayObject $responses = null, private ?\ArrayObject $parameters = null, private ?\ArrayObject $examples = null, private ?\ArrayObject $requestBodies = null, private ?\ArrayObject $headers = null, private ?\ArrayObject $securitySchemes = null, private ?\ArrayObject $links = null, private ?\ArrayObject $callbacks = null, private ?\ArrayObject $pathItems = null)
35+
public function __construct(?\ArrayObject $schemas = null, private ?\ArrayObject $responses = null, private ?\ArrayObject $parameters = null, private ?\ArrayObject $examples = null, private ?\ArrayObject $requestBodies = null, private ?\ArrayObject $headers = null, private ?\ArrayObject $securitySchemes = null, private ?\ArrayObject $links = null, private ?\ArrayObject $callbacks = null, private ?\ArrayObject $pathItems = null, private ?\ArrayObject $mediaTypes = null)
3536
{
3637
$schemas?->ksort();
3738

@@ -88,6 +89,11 @@ public function getPathItems(): ?\ArrayObject
8889
return $this->pathItems;
8990
}
9091

92+
public function getMediaTypes(): ?\ArrayObject
93+
{
94+
return $this->mediaTypes;
95+
}
96+
9197
public function withSchemas(\ArrayObject $schemas): self
9298
{
9399
$clone = clone $this;
@@ -167,4 +173,12 @@ public function withPathItems(\ArrayObject $pathItems): self
167173

168174
return $clone;
169175
}
176+
177+
public function withMediaTypes(\ArrayObject $mediaTypes): self
178+
{
179+
$clone = clone $this;
180+
$clone->mediaTypes = $mediaTypes;
181+
182+
return $clone;
183+
}
170184
}

src/OpenApi/Model/Encoding.php

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ final class Encoding
1717
{
1818
use ExtensionTrait;
1919

20-
public function __construct(private string $contentType = '', private ?\ArrayObject $headers = null, private string $style = '', private bool $explode = false, private bool $allowReserved = false)
20+
/**
21+
* @param array<int, Encoding>|null $prefixEncoding
22+
*/
23+
public function __construct(private string $contentType = '', private ?\ArrayObject $headers = null, private string $style = '', private bool $explode = false, private bool $allowReserved = false, private ?\ArrayObject $encoding = null, private ?array $prefixEncoding = null, private ?self $itemEncoding = null)
2124
{
2225
}
2326

@@ -56,6 +59,24 @@ public function getAllowReserved(): bool
5659
return $this->allowReserved;
5760
}
5861

62+
public function getEncoding(): ?\ArrayObject
63+
{
64+
return $this->encoding;
65+
}
66+
67+
/**
68+
* @return array<int, Encoding>|null
69+
*/
70+
public function getPrefixEncoding(): ?array
71+
{
72+
return $this->prefixEncoding;
73+
}
74+
75+
public function getItemEncoding(): ?self
76+
{
77+
return $this->itemEncoding;
78+
}
79+
5980
public function withContentType(string $contentType): self
6081
{
6182
$clone = clone $this;
@@ -95,4 +116,31 @@ public function withAllowReserved(bool $allowReserved): self
95116

96117
return $clone;
97118
}
119+
120+
public function withEncoding(?\ArrayObject $encoding): self
121+
{
122+
$clone = clone $this;
123+
$clone->encoding = $encoding;
124+
125+
return $clone;
126+
}
127+
128+
/**
129+
* @param array<int, Encoding>|null $prefixEncoding
130+
*/
131+
public function withPrefixEncoding(?array $prefixEncoding): self
132+
{
133+
$clone = clone $this;
134+
$clone->prefixEncoding = $prefixEncoding;
135+
136+
return $clone;
137+
}
138+
139+
public function withItemEncoding(self $itemEncoding): self
140+
{
141+
$clone = clone $this;
142+
$clone->itemEncoding = $itemEncoding;
143+
144+
return $clone;
145+
}
98146
}

src/OpenApi/Model/Example.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class Example
1717
{
1818
use ExtensionTrait;
1919

20-
public function __construct(private ?string $summary = null, private ?string $description = null, private mixed $value = null, private ?string $externalValue = null)
20+
public function __construct(private ?string $summary = null, private ?string $description = null, private mixed $value = null, private ?string $externalValue = null, private mixed $dataValue = null, private ?string $serializedValue = null)
2121
{
2222
}
2323

@@ -72,4 +72,30 @@ public function withExternalValue(string $externalValue): self
7272

7373
return $clone;
7474
}
75+
76+
public function getDataValue(): mixed
77+
{
78+
return $this->dataValue;
79+
}
80+
81+
public function withDataValue(mixed $dataValue): self
82+
{
83+
$clone = clone $this;
84+
$clone->dataValue = $dataValue;
85+
86+
return $clone;
87+
}
88+
89+
public function getSerializedValue(): ?string
90+
{
91+
return $this->serializedValue;
92+
}
93+
94+
public function withSerializedValue(string $serializedValue): self
95+
{
96+
$clone = clone $this;
97+
$clone->serializedValue = $serializedValue;
98+
99+
return $clone;
100+
}
75101
}

src/OpenApi/Model/MediaType.php

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ final class MediaType
1717
{
1818
use ExtensionTrait;
1919

20-
public function __construct(private ?\ArrayObject $schema = null, private mixed $example = null, private ?\ArrayObject $examples = null, private ?Encoding $encoding = null)
20+
/**
21+
* @param array<int, Encoding>|null $prefixEncoding
22+
*/
23+
public function __construct(private ?\ArrayObject $schema = null, private mixed $example = null, private ?\ArrayObject $examples = null, private ?Encoding $encoding = null, private ?\ArrayObject $itemSchema = null, private ?array $prefixEncoding = null, private ?Encoding $itemEncoding = null)
2124
{
2225
}
2326

@@ -41,6 +44,24 @@ public function getEncoding(): ?Encoding
4144
return $this->encoding;
4245
}
4346

47+
public function getItemSchema(): ?\ArrayObject
48+
{
49+
return $this->itemSchema;
50+
}
51+
52+
/**
53+
* @return array<int, Encoding>|null
54+
*/
55+
public function getPrefixEncoding(): ?array
56+
{
57+
return $this->prefixEncoding;
58+
}
59+
60+
public function getItemEncoding(): ?Encoding
61+
{
62+
return $this->itemEncoding;
63+
}
64+
4465
public function withSchema(\ArrayObject $schema): self
4566
{
4667
$clone = clone $this;
@@ -72,4 +93,31 @@ public function withEncoding(Encoding $encoding): self
7293

7394
return $clone;
7495
}
96+
97+
public function withItemSchema(\ArrayObject $itemSchema): self
98+
{
99+
$clone = clone $this;
100+
$clone->itemSchema = $itemSchema;
101+
102+
return $clone;
103+
}
104+
105+
/**
106+
* @param array<int, Encoding>|null $prefixEncoding
107+
*/
108+
public function withPrefixEncoding(?array $prefixEncoding): self
109+
{
110+
$clone = clone $this;
111+
$clone->prefixEncoding = $prefixEncoding;
112+
113+
return $clone;
114+
}
115+
116+
public function withItemEncoding(Encoding $itemEncoding): self
117+
{
118+
$clone = clone $this;
119+
$clone->itemEncoding = $itemEncoding;
120+
121+
return $clone;
122+
}
75123
}

src/OpenApi/Model/OAuthFlow.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class OAuthFlow
1717
{
1818
use ExtensionTrait;
1919

20-
public function __construct(private ?string $authorizationUrl = null, private ?string $tokenUrl = null, private ?string $refreshUrl = null, private ?\ArrayObject $scopes = null)
20+
public function __construct(private ?string $authorizationUrl = null, private ?string $tokenUrl = null, private ?string $refreshUrl = null, private ?\ArrayObject $scopes = null, private ?string $deviceAuthorizationUrl = null)
2121
{
2222
}
2323

@@ -41,6 +41,11 @@ public function getScopes(): \ArrayObject
4141
return $this->scopes;
4242
}
4343

44+
public function getDeviceAuthorizationUrl(): ?string
45+
{
46+
return $this->deviceAuthorizationUrl;
47+
}
48+
4449
public function withAuthorizationUrl(string $authorizationUrl): self
4550
{
4651
$clone = clone $this;
@@ -72,4 +77,12 @@ public function withScopes(\ArrayObject $scopes): self
7277

7378
return $clone;
7479
}
80+
81+
public function withDeviceAuthorizationUrl(string $deviceAuthorizationUrl): self
82+
{
83+
$clone = clone $this;
84+
$clone->deviceAuthorizationUrl = $deviceAuthorizationUrl;
85+
86+
return $clone;
87+
}
7588
}

src/OpenApi/Model/OAuthFlows.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class OAuthFlows
1717
{
1818
use ExtensionTrait;
1919

20-
public function __construct(private ?OAuthFlow $implicit = null, private ?OAuthFlow $password = null, private ?OAuthFlow $clientCredentials = null, private ?OAuthFlow $authorizationCode = null)
20+
public function __construct(private ?OAuthFlow $implicit = null, private ?OAuthFlow $password = null, private ?OAuthFlow $clientCredentials = null, private ?OAuthFlow $authorizationCode = null, private ?OAuthFlow $deviceAuthorization = null)
2121
{
2222
}
2323

@@ -41,6 +41,11 @@ public function getAuthorizationCode(): ?OAuthFlow
4141
return $this->authorizationCode;
4242
}
4343

44+
public function getDeviceAuthorization(): ?OAuthFlow
45+
{
46+
return $this->deviceAuthorization;
47+
}
48+
4449
public function withImplicit(OAuthFlow $implicit): self
4550
{
4651
$clone = clone $this;
@@ -72,4 +77,12 @@ public function withAuthorizationCode(OAuthFlow $authorizationCode): self
7277

7378
return $clone;
7479
}
80+
81+
public function withDeviceAuthorization(OAuthFlow $deviceAuthorization): self
82+
{
83+
$clone = clone $this;
84+
$clone->deviceAuthorization = $deviceAuthorization;
85+
86+
return $clone;
87+
}
7588
}

src/OpenApi/Model/PathItem.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class PathItem
1919

2020
public static array $methods = ['GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'HEAD', 'PATCH', 'TRACE'];
2121

22-
public function __construct(private ?string $ref = null, private ?string $summary = null, private ?string $description = null, private ?Operation $get = null, private ?Operation $put = null, private ?Operation $post = null, private ?Operation $delete = null, private ?Operation $options = null, private ?Operation $head = null, private ?Operation $patch = null, private ?Operation $trace = null, private ?array $servers = null, private ?array $parameters = null)
22+
public function __construct(private ?string $ref = null, private ?string $summary = null, private ?string $description = null, private ?Operation $get = null, private ?Operation $put = null, private ?Operation $post = null, private ?Operation $delete = null, private ?Operation $options = null, private ?Operation $head = null, private ?Operation $patch = null, private ?Operation $trace = null, private ?array $servers = null, private ?array $parameters = null, private ?Operation $query = null, private ?array $additionalOperations = null)
2323
{
2424
}
2525

@@ -88,6 +88,19 @@ public function getParameters(): ?array
8888
return $this->parameters;
8989
}
9090

91+
public function getQuery(): ?Operation
92+
{
93+
return $this->query;
94+
}
95+
96+
/**
97+
* @return array<string, Operation>|null
98+
*/
99+
public function getAdditionalOperations(): ?array
100+
{
101+
return $this->additionalOperations;
102+
}
103+
91104
public function withRef(string $ref): self
92105
{
93106
$clone = clone $this;
@@ -191,4 +204,23 @@ public function withParameters(?array $parameters = null): self
191204

192205
return $clone;
193206
}
207+
208+
public function withQuery(?Operation $query): self
209+
{
210+
$clone = clone $this;
211+
$clone->query = $query;
212+
213+
return $clone;
214+
}
215+
216+
/**
217+
* @param array<string, Operation>|null $additionalOperations
218+
*/
219+
public function withAdditionalOperations(?array $additionalOperations = null): self
220+
{
221+
$clone = clone $this;
222+
$clone->additionalOperations = $additionalOperations;
223+
224+
return $clone;
225+
}
194226
}

src/OpenApi/Model/Response.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class Response
1717
{
1818
use ExtensionTrait;
1919

20-
public function __construct(private ?string $description = null, private ?\ArrayObject $content = null, private ?\ArrayObject $headers = null, private ?\ArrayObject $links = null)
20+
public function __construct(private ?string $description = null, private ?\ArrayObject $content = null, private ?\ArrayObject $headers = null, private ?\ArrayObject $links = null, private ?string $summary = null)
2121
{
2222
}
2323

@@ -41,6 +41,11 @@ public function getLinks(): ?\ArrayObject
4141
return $this->links;
4242
}
4343

44+
public function getSummary(): ?string
45+
{
46+
return $this->summary;
47+
}
48+
4449
public function withDescription(string $description): self
4550
{
4651
$clone = clone $this;
@@ -72,4 +77,12 @@ public function withLinks(\ArrayObject $links): self
7277

7378
return $clone;
7479
}
80+
81+
public function withSummary(string $summary): self
82+
{
83+
$clone = clone $this;
84+
$clone->summary = $summary;
85+
86+
return $clone;
87+
}
7588
}

0 commit comments

Comments
 (0)