Skip to content

Commit

Permalink
4.40.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Feb 3, 2025
1 parent 99b71eb commit 1ad707f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

### Removed

# 4.40.0 (3 February 2024)
## Added
- Correctly list required fields for nested objects in OpenAPI spec (request bodies) [99b71ebf0](https://github.com/knuckleswtf/scribe/commit/99b71ebf058e679c3020779583be4de6b576ba3b)
- Add support for defining Groups and Subgroups as enums [#932](https://github.com/knuckleswtf/scribe/pull/932)

# 4.39.0 (31 December 2024)
## Added
- Correctly list required fields for nested objects in OpenAPI spec [#905](https://github.com/knuckleswtf/scribe/pull/905)
- Correctly list required fields for nested objects in OpenAPI spec (responses) [#905](https://github.com/knuckleswtf/scribe/pull/905)
- Cursor pagination support in API responses (`cursorPaginate`/`paginate=cursor`) [#917](https://github.com/knuckleswtf/scribe/pull/917)

## Fixed
Expand Down
1 change: 1 addition & 0 deletions src/Commands/GenerateDocumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function handle(RouteMatcherInterface $routeMatcher, GroupedEndpointsFact
$this->writeExampleCustomEndpoint();
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/Scribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class Scribe
{
public const VERSION = '4.39.0';
public const VERSION = '4.40.0';

/**
* Specify a callback that will be executed just before a response call is made
Expand Down
7 changes: 6 additions & 1 deletion src/Writing/OpenAPISpecWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ public function generateFieldData($field): array

return $fieldData;
} else if ($field->type === 'object') {
return [
$data = [
'type' => 'object',
'description' => $field->description ?: '',
'example' => $field->example,
Expand All @@ -553,6 +553,11 @@ public function generateFieldData($field): array
})->all()),
'required' => collect($field->__fields)->filter(fn ($f) => $f['required'])->keys()->toArray(),
];
// The spec doesn't allow for an empty `required` array. Must have something there.
if (empty($data['required'])) {
unset($data['required']);
}
return $data;
} else {
$schema = [
'type' => static::normalizeTypeName($field->type),
Expand Down

0 comments on commit 1ad707f

Please sign in to comment.