Skip to content

Commit e3013d4

Browse files
authored
Revert "fix(jsonschema): make all required properties optional in PATCH opera…" (#6476)
This reverts commit 842091d.
1 parent aeca014 commit e3013d4

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/JsonSchema/SchemaFactory.php

+1-11
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use ApiPlatform\Metadata\CollectionOperationInterface;
1919
use ApiPlatform\Metadata\HttpOperation;
2020
use ApiPlatform\Metadata\Operation;
21-
use ApiPlatform\Metadata\Patch;
2221
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
2322
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
2423
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
@@ -34,9 +33,6 @@
3433
final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareInterface
3534
{
3635
use ResourceMetadataTrait;
37-
38-
private const PATCH_SCHEMA_POSTFIX = '.patch';
39-
4036
private ?TypeFactoryInterface $typeFactory = null;
4137
private ?SchemaFactoryInterface $schemaFactory = null;
4238
// Edge case where the related resource is not readable (for example: NotExposed) but we have groups to read the whole related object
@@ -92,12 +88,6 @@ public function buildSchema(string $className, string $format = 'json', string $
9288
return $schema;
9389
}
9490

95-
$isJsonMergePatch = 'json' === $format && $operation instanceof Patch && Schema::TYPE_INPUT === $type;
96-
97-
if ($isJsonMergePatch) {
98-
$definitionName .= self::PATCH_SCHEMA_POSTFIX;
99-
}
100-
10191
if (!isset($schema['$ref']) && !isset($schema['type'])) {
10292
$ref = Schema::VERSION_OPENAPI === $version ? '#/components/schemas/'.$definitionName : '#/definitions/'.$definitionName;
10393
if ($forceCollection || ('POST' !== $method && $operation instanceof CollectionOperationInterface)) {
@@ -146,7 +136,7 @@ public function buildSchema(string $className, string $format = 'json', string $
146136
}
147137

148138
$normalizedPropertyName = $this->nameConverter ? $this->nameConverter->normalize($propertyName, $inputOrOutputClass, $format, $serializerContext) : $propertyName;
149-
if ($propertyMetadata->isRequired() && !$isJsonMergePatch) {
139+
if ($propertyMetadata->isRequired()) {
150140
$definition['required'][] = $normalizedPropertyName;
151141
}
152142

0 commit comments

Comments
 (0)