Skip to content

Commit

Permalink
fix: default format and standard_put values
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka authored and dunglas committed Sep 20, 2024
1 parent fcb78ea commit c47e299
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Doctrine/Common/State/PersistProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
// PUT: reset the existing object managed by Doctrine and merge data sent by the user in it
// This custom logic is needed because EntityManager::merge() has been deprecated and UPSERT isn't supported:
// https://github.com/doctrine/orm/issues/8461#issuecomment-1250233555
if ($operation instanceof HttpOperation && 'PUT' === $operation->getMethod() && ($operation->getExtraProperties()['standard_put'] ?? false)) {
if ($operation instanceof HttpOperation && 'PUT' === $operation->getMethod() && ($operation->getExtraProperties()['standard_put'] ?? true)) {
\assert(method_exists($manager, 'getReference'));
$newData = $data;
$identifiers = array_reverse($uriVariables);
Expand Down
2 changes: 1 addition & 1 deletion src/JsonLd/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function denormalize(mixed $data, string $class, ?string $format = null,
} catch (ItemNotFoundException $e) {
$operation = $context['operation'] ?? null;

if (!('PUT' === $operation?->getMethod() && ($operation->getExtraProperties()['standard_put'] ?? false))) {
if (!('PUT' === $operation?->getMethod() && ($operation->getExtraProperties()['standard_put'] ?? true))) {
throw $e;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/State/Provider/DeserializeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
&& (
'POST' === $method
|| 'PATCH' === $method
|| ('PUT' === $method && !($operation->getExtraProperties()['standard_put'] ?? false))
|| ('PUT' === $method && !($operation->getExtraProperties()['standard_put'] ?? true))
)
) {
$serializerContext[AbstractNormalizer::OBJECT_TO_POPULATE] = $data;
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public function getConfigTreeBuilder(): TreeBuilder
$this->addExceptionToStatusSection($rootNode);

$this->addFormatSection($rootNode, 'formats', [
'jsonld' => ['mime_types' => ['application/ld+json']]
]);
$this->addFormatSection($rootNode, 'patch_formats', [
'json' => ['mime_types' => ['application/merge-patch+json']],
Expand Down
3 changes: 0 additions & 3 deletions tests/Fixtures/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,6 @@ class_exists(NativePasswordHasher::class) ? 'password_hashers' : 'encoders' => [
'public' => true,
],
'normalization_context' => ['skip_null_values' => false],
'extra_properties' => [
'standard_put' => true,
],
'operations' => [
Get::class,
GetCollection::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ private function runDefaultConfigTests(array $doctrineIntegrationsToLoad = ['orm
'description' => 'description',
'version' => '1.0.0',
'show_webby' => true,
'formats' => [],
'formats' => [
'jsonld' => ['mime_types' => ['application/ld+json']],
],
'docs_formats' => [
'jsonopenapi' => ['mime_types' => ['application/vnd.openapi+json']],
'yamlopenapi' => ['mime_types' => ['application/vnd.openapi+yaml']],
Expand Down

0 comments on commit c47e299

Please sign in to comment.