From 6346c539c05b4ee191b32e3afcf72e6c1b9d1395 Mon Sep 17 00:00:00 2001 From: KavajNaruj Date: Tue, 11 Nov 2025 15:40:25 +0100 Subject: [PATCH 1/3] Update OpenApiHandler.php --- src/Handlers/OpenApiHandler.php | 39 +++++++++++++-------------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/src/Handlers/OpenApiHandler.php b/src/Handlers/OpenApiHandler.php index 7f372c4..e429980 100644 --- a/src/Handlers/OpenApiHandler.php +++ b/src/Handlers/OpenApiHandler.php @@ -484,6 +484,7 @@ private function createRequestBody(ApiHandlerInterface $handler) ]; $filesInBody = false; $requestBodyExample = []; + $result = []; foreach ($handler->params() as $param) { if ($param instanceof JsonInputParam) { $schema = json_decode($param->getSchema(), true); @@ -496,14 +497,11 @@ private function createRequestBody(ApiHandlerInterface $handler) } } } - return [ - 'description' => $param->getDescription(), - 'required' => $param->isRequired(), - 'content' => [ - 'application/json' => [ - 'schema' => $this->transformSchema($schema), - ], - ], + + $result['description'] = $param->getDescription(); + $result['required'] = $param->isRequired(); + $result['content']['application/json'] = [ + 'schema' => $this->transformSchema($schema), ]; } if ($param instanceof RawInputParam) { @@ -517,14 +515,10 @@ private function createRequestBody(ApiHandlerInterface $handler) $schema['examples'] = $examples; } } - return [ - 'description' => $param->getDescription(), - 'required' => $param->isRequired(), - 'content' => [ - 'text/plain' => [ - 'schema' => $schema, - ], - ], + $result['description'] ??= $param->getDescription(); + $result['required'] ??= $param->isRequired(); + $result['content']['text/plain'] = [ + 'schema' => $schema, ]; } if ($param->getType() === InputParam::TYPE_POST || $param->getType() === InputParam::TYPE_PUT) { @@ -594,17 +588,14 @@ private function createRequestBody(ApiHandlerInterface $handler) } $contentType = $filesInBody ? 'multipart/form-data' : 'application/x-www-form-urlencoded'; - return [ - 'required' => true, - 'content' => [ - $contentType => [ - 'schema' => $requestBodySchema, - ], - ], + + $result['required'] = true; + $result['content'][$contentType] = [ + 'schema' => $requestBodySchema, ]; } - return null; + return $result ?: null; } private function createIn($type) From 2d244351091d13b73c10cc8495e79ef5dfaf1b26 Mon Sep 17 00:00:00 2001 From: KavajNaruj Date: Tue, 11 Nov 2025 15:42:51 +0100 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index acede3f..7e18498 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. ## [Unreleased][unreleased] +### Changed +* Update Request body schema in OpenApiHandler + + ## 3.0.0 From 67624c739c4072a45fe4bf3275aa8a6cea4b4eec Mon Sep 17 00:00:00 2001 From: Juraj Vanak Date: Tue, 25 Nov 2025 09:25:49 +0100 Subject: [PATCH 3/3] Support for php7.1 --- src/Handlers/OpenApiHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Handlers/OpenApiHandler.php b/src/Handlers/OpenApiHandler.php index e429980..cd882c0 100644 --- a/src/Handlers/OpenApiHandler.php +++ b/src/Handlers/OpenApiHandler.php @@ -515,8 +515,8 @@ private function createRequestBody(ApiHandlerInterface $handler) $schema['examples'] = $examples; } } - $result['description'] ??= $param->getDescription(); - $result['required'] ??= $param->isRequired(); + $result['description'] = $result['description'] ?? $param->getDescription(); + $result['required'] = $result['required'] ?? $param->isRequired(); $result['content']['text/plain'] = [ 'schema' => $schema, ];