From 405f9dc0dac7171f372331cdd6700df06f97054d Mon Sep 17 00:00:00 2001 From: Peter Krupa Date: Fri, 25 Oct 2024 12:38:18 +0200 Subject: [PATCH] Fixing issue #903 - required response fields - added check for `required` fields to the loop inspecting nested object --- src/Writing/OpenAPISpecWriter.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Writing/OpenAPISpecWriter.php b/src/Writing/OpenAPISpecWriter.php index 0356f5e0..41e1fb46 100644 --- a/src/Writing/OpenAPISpecWriter.php +++ b/src/Writing/OpenAPISpecWriter.php @@ -635,6 +635,11 @@ public function generateSchemaForValue(mixed $value, OutputEndpointData $endpoin $schema['items']['properties'] = collect($sample)->mapWithKeys(function ($v, $k) use ($endpoint, $path) { return [$k => $this->generateSchemaForValue($v, $endpoint, "$path.$k")]; })->toArray(); + + $required = $this->filterRequiredFields($endpoint, array_keys($schema['items']['properties']), $path); + if ($required) { + $schema['required'] = $required; + } } }