Skip to content

Commit

Permalink
Fixing issue knuckleswtf#903 - required response fields
Browse files Browse the repository at this point in the history
- added check for `required` fields to the loop inspecting nested object
  • Loading branch information
peter-krupa committed Oct 25, 2024
1 parent da667aa commit 405f9dc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Writing/OpenAPISpecWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit 405f9dc

Please sign in to comment.