From e404ed2fae956318ba7c2ab4fce0370bccd3e377 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 7014020afc4..1583202ea05 100644 --- a/src/JsonSchema/SchemaFactory.php +++ b/src/JsonSchema/SchemaFactory.php @@ -80,6 +80,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(); $method = $operation instanceof HttpOperation ? $operation->getMethod() : 'GET';