Shalvah 2 月之前
父节点
当前提交
020b50d7e4
共有 1 个文件被更改,包括 50 次插入1 次删除
  1. 50 1
      tests/Unit/OpenAPISpecWriterTest.php

+ 50 - 1
tests/Unit/OpenAPISpecWriterTest.php

@@ -601,7 +601,7 @@ class OpenAPISpecWriterTest extends BaseUnitTest
     }
 
     /** @test */
-    public function adds_required_fields_on_objects_wrapped_in_array()
+    public function adds_required_fields_on_array_of_objects()
     {
         $endpointData = $this->createMockEndpointData([
             'httpMethods' => ['GEt'],
@@ -686,6 +686,55 @@ class OpenAPISpecWriterTest extends BaseUnitTest
         ], $results['paths']['/path1']['get']['responses']);
     }
 
+    /** @test */
+    public function generates_correctly_for_array_of_strings()
+    {
+        $endpointData = $this->createMockEndpointData([
+            'httpMethods' => ['GET'],
+            'uri' => '/path1',
+            'responses' => [
+                [
+                    'status' => 200,
+                    'description' => 'List of entities',
+                    'content' => '{"data":["Resource name"]}',
+                ],
+            ],
+            'responseFields' => [
+                'data' => [
+                    'name' => 'data',
+                    'type' => 'string[]',
+                    'description' => 'Data wrapper',
+                ],
+            ],
+        ]);
+
+        $groups = [$this->createGroup([$endpointData])];
+
+        $results = $this->generate($groups);
+
+        $this->assertArraySubset([
+            '200' => [
+                'description' => 'List of entities',
+                'content' => [
+                    'application/json' => [
+                        'schema' => [
+                            'type' => 'object',
+                            'properties' => [
+                                'data' => [
+                                    'type' => 'array',
+                                    'description' => 'Data wrapper',
+                                    'items' => [
+                                        'type' => 'string',
+                                    ],
+                                ],
+                            ],
+                        ],
+                    ],
+                ],
+            ],
+        ], $results['paths']['/path1']['get']['responses']);
+    }
+
     /** @test */
     public function adds_multiple_responses_correctly_using_oneOf()
     {