Shalvah 3 ay önce
ebeveyn
işleme
1ad707f229

+ 6 - 1
CHANGELOG.md

@@ -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

+ 1 - 0
src/Commands/GenerateDocumentation.php

@@ -63,6 +63,7 @@ class GenerateDocumentation extends Command
             $this->writeExampleCustomEndpoint();
         }
 
+        /** @var Writer $writer */
         $writer = app(Writer::class, ['config' => $this->docConfig, 'paths' => $this->paths]);
         $writer->writeDocs($groupedEndpoints);
 

+ 1 - 1
src/Scribe.php

@@ -9,7 +9,7 @@ use Symfony\Component\HttpFoundation\Request;
 
 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

+ 6 - 1
src/Writing/OpenAPISpecWriter.php

@@ -543,7 +543,7 @@ class OpenAPISpecWriter
 
             return $fieldData;
         } else if ($field->type === 'object') {
-            return [
+            $data = [
                 'type' => 'object',
                 'description' => $field->description ?: '',
                 'example' => $field->example,
@@ -553,6 +553,11 @@ class OpenAPISpecWriter
                 })->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),