Skip to content

Commit 1ad707f

Browse files
committed
4.40.0
1 parent 99b71eb commit 1ad707f

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1212

1313
### Removed
1414

15+
# 4.40.0 (3 February 2024)
16+
## Added
17+
- Correctly list required fields for nested objects in OpenAPI spec (request bodies) [99b71ebf0](https://github.com/knuckleswtf/scribe/commit/99b71ebf058e679c3020779583be4de6b576ba3b)
18+
- Add support for defining Groups and Subgroups as enums [#932](https://github.com/knuckleswtf/scribe/pull/932)
19+
1520
# 4.39.0 (31 December 2024)
1621
## Added
17-
- Correctly list required fields for nested objects in OpenAPI spec [#905](https://github.com/knuckleswtf/scribe/pull/905)
22+
- Correctly list required fields for nested objects in OpenAPI spec (responses) [#905](https://github.com/knuckleswtf/scribe/pull/905)
1823
- Cursor pagination support in API responses (`cursorPaginate`/`paginate=cursor`) [#917](https://github.com/knuckleswtf/scribe/pull/917)
1924

2025
## Fixed

src/Commands/GenerateDocumentation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function handle(RouteMatcherInterface $routeMatcher, GroupedEndpointsFact
6363
$this->writeExampleCustomEndpoint();
6464
}
6565

66+
/** @var Writer $writer */
6667
$writer = app(Writer::class, ['config' => $this->docConfig, 'paths' => $this->paths]);
6768
$writer->writeDocs($groupedEndpoints);
6869

src/Scribe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class Scribe
1111
{
12-
public const VERSION = '4.39.0';
12+
public const VERSION = '4.40.0';
1313

1414
/**
1515
* Specify a callback that will be executed just before a response call is made

src/Writing/OpenAPISpecWriter.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ public function generateFieldData($field): array
543543

544544
return $fieldData;
545545
} else if ($field->type === 'object') {
546-
return [
546+
$data = [
547547
'type' => 'object',
548548
'description' => $field->description ?: '',
549549
'example' => $field->example,
@@ -553,6 +553,11 @@ public function generateFieldData($field): array
553553
})->all()),
554554
'required' => collect($field->__fields)->filter(fn ($f) => $f['required'])->keys()->toArray(),
555555
];
556+
// The spec doesn't allow for an empty `required` array. Must have something there.
557+
if (empty($data['required'])) {
558+
unset($data['required']);
559+
}
560+
return $data;
556561
} else {
557562
$schema = [
558563
'type' => static::normalizeTypeName($field->type),

0 commit comments

Comments
 (0)