Skip to content

Commit 62bd9df

Browse files
authored
Add contentEncoding and contentMediaType to Schema (#1831)
1 parent 2b94ee9 commit 62bd9df

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

src/Annotations/Schema.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,22 @@ class Schema extends AbstractAnnotation
428428
*/
429429
public $const = Generator::UNDEFINED;
430430

431+
/**
432+
* https://spec.openapis.org/oas/v3.1.0.html#considerations-for-file-uploads
433+
* https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.8.3.
434+
*
435+
* @var string
436+
*/
437+
public $contentEncoding = Generator::UNDEFINED;
438+
439+
/**
440+
* https://spec.openapis.org/oas/v3.1.0.html#considerations-for-file-uploads
441+
* https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-00#rfc.section.8.4.
442+
*
443+
* @var string
444+
*/
445+
public $contentMediaType = Generator::UNDEFINED;
446+
431447
/**
432448
* @inheritdoc
433449
*/
@@ -451,6 +467,8 @@ class Schema extends AbstractAnnotation
451467
'allOf' => '[' . Schema::class . ']',
452468
'oneOf' => '[' . Schema::class . ']',
453469
'anyOf' => '[' . Schema::class . ']',
470+
'contentEncoding' => 'string',
471+
'contentMediaType' => 'string',
454472
];
455473

456474
/**

src/Attributes/JsonContent.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public function __construct(
8787
?array $anyOf = null,
8888
?array $oneOf = null,
8989
AdditionalProperties|bool|null $additionalProperties = null,
90+
?string $contentEncoding = null,
91+
?string $contentMediaType = null,
9092
// annotation
9193
?array $x = null,
9294
?array $attachables = null
@@ -127,6 +129,8 @@ public function __construct(
127129
'anyOf' => $anyOf ?? Generator::UNDEFINED,
128130
'oneOf' => $oneOf ?? Generator::UNDEFINED,
129131
'additionalProperties' => $additionalProperties ?? Generator::UNDEFINED,
132+
'contentEncoding' => $contentEncoding ?? Generator::UNDEFINED,
133+
'contentMediaType' => $contentMediaType ?? Generator::UNDEFINED,
130134
// annotation
131135
'x' => $x ?? Generator::UNDEFINED,
132136
'attachables' => $attachables ?? Generator::UNDEFINED,

src/Attributes/Schema.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public function __construct(
6767
?array $oneOf = null,
6868
AdditionalProperties|bool|null $additionalProperties = null,
6969
mixed $const = Generator::UNDEFINED,
70+
?string $contentEncoding = null,
71+
?string $contentMediaType = null,
7072
// annotation
7173
?array $x = null,
7274
?array $attachables = null
@@ -106,6 +108,8 @@ public function __construct(
106108
'oneOf' => $oneOf ?? Generator::UNDEFINED,
107109
'additionalProperties' => $additionalProperties ?? Generator::UNDEFINED,
108110
'const' => $const,
111+
'contentEncoding' => $contentEncoding ?? Generator::UNDEFINED,
112+
'contentMediaType' => $contentMediaType ?? Generator::UNDEFINED,
109113
'x' => $x ?? Generator::UNDEFINED,
110114
'attachables' => $attachables ?? Generator::UNDEFINED,
111115
'value' => $this->combine($items, $discriminator, $externalDocs, $examples),

src/Attributes/XmlContent.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public function __construct(
6666
?array $anyOf = null,
6767
?array $oneOf = null,
6868
AdditionalProperties|bool|null $additionalProperties = null,
69+
?string $contentEncoding = null,
70+
?string $contentMediaType = null,
6971
// annotation
7072
?array $x = null,
7173
?array $attachables = null
@@ -106,6 +108,8 @@ public function __construct(
106108
'anyOf' => $anyOf ?? Generator::UNDEFINED,
107109
'oneOf' => $oneOf ?? Generator::UNDEFINED,
108110
'additionalProperties' => $additionalProperties ?? Generator::UNDEFINED,
111+
'contentEncoding' => $contentEncoding ?? Generator::UNDEFINED,
112+
'contentMediaType' => $contentMediaType ?? Generator::UNDEFINED,
109113
// annotation
110114
'x' => $x ?? Generator::UNDEFINED,
111115
'attachables' => $attachables ?? Generator::UNDEFINED,

tests/Annotations/AttributesSyncTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,23 @@ public function testParameterCompleteness(string $annotation): void
6363
unset($typeMismatch['required']);
6464
}
6565
if (!$found) {
66-
// exclusions...
66+
// Schema inheritance exclusions...
6767
if ($attributeRC->isSubclassOf(OA\Operation::class) && in_array($propertyName, ['method'])) {
6868
continue;
6969
}
7070
if ($attributeRC->isSubclassOf(OA\Attachable::class) && in_array($propertyName, ['x'])) {
7171
continue;
7272
}
73-
if ($attributeRC->isSubclassOf(OA\AdditionalProperties::class) && in_array($propertyName, ['additionalProperties', 'examples'])) {
73+
if ($attributeRC->isSubclassOf(OA\AdditionalProperties::class) && in_array($propertyName, ['additionalProperties', 'examples', 'contentEncoding', 'contentMediaType'])) {
7474
continue;
7575
}
76-
if ($attributeRC->isSubclassOf(OA\Items::class) && in_array($propertyName, ['examples'])) {
76+
if ($attributeRC->isSubclassOf(OA\Items::class) && in_array($propertyName, ['examples', 'contentEncoding', 'contentMediaType'])) {
7777
continue;
7878
}
79-
if ($attributeRC->isSubclassOf(OA\Property::class) && in_array($propertyName, ['examples'])) {
79+
if ($attributeRC->isSubclassOf(OA\Property::class) && in_array($propertyName, ['examples', 'contentEncoding', 'contentMediaType'])) {
8080
continue;
8181
}
82+
8283
if (in_array($propertyName, static::$SCHEMA_EXCLUSIONS)) {
8384
continue;
8485
}

0 commit comments

Comments
 (0)