From 97093c08dd6fefc011fe52d96ae93076da5817bd Mon Sep 17 00:00:00 2001 From: Eric GELOEN Date: Mon, 1 Apr 2024 21:57:18 +0200 Subject: [PATCH] [JsonSchema] Only build schemas which can be serialized / deserialied --- src/JsonSchema/SchemaFactory.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/JsonSchema/SchemaFactory.php b/src/JsonSchema/SchemaFactory.php index 097eaddd4b..ea25a99c98 100644 --- a/src/JsonSchema/SchemaFactory.php +++ b/src/JsonSchema/SchemaFactory.php @@ -74,6 +74,14 @@ public function buildSchema(string $className, string $format = 'json', string $ return $schema; } + if ('input' === $type && !($operation?->canDeserialize() ?? true)) { + return $schema; + } + + if ('output' === $type && !($operation?->canSerialize() ?? true)) { + return $schema; + } + $validationGroups = $operation ? $this->getValidationGroups($operation) : []; $version = $schema->getVersion(); $definitionName = $this->definitionNameFactory->create($className, $format, $inputOrOutputClass, $operation, $serializerContext);