12
12
use Symfony \Bundle \FrameworkBundle \KernelBrowser ;
13
13
use Symfony \Bundle \FrameworkBundle \Test \WebTestCase ;
14
14
use Symfony \Component \HttpFoundation \Response ;
15
- use Symfony \Component \HttpKernel \Kernel ;
16
15
17
16
final class NelmioApiDocsTest extends WebTestCase
18
17
{
@@ -50,6 +49,7 @@ public function testGetJsonDocs(): void
50
49
$ this ->verifyReturnTypeRoute ('/test-return-type/{id} ' , $ content );
51
50
$ this ->verifyBuiltinReturnTypeRoute ('/test-builtin-return-type/{id} ' , $ content );
52
51
$ this ->verifyAnnotationBuiltinArrayReturnTypeRoute ('/annotation-builtin-type-array/{id} ' , $ content );
52
+ $ this ->verifyAnnotationGenericReturnTypeRoute ('/test-generic-return-type/{id} ' , $ content );
53
53
$ this ->verifyAnnotationCustomArrayReturnTypeRoute ('/test-annotation-custom-return-type/{id} ' , $ content );
54
54
$ this ->verifyPostRouteWithTag ('/test-post-route-with-tag/{id} ' , $ content );
55
55
$ this ->verifyCombinedAttributesRoute ('/test-combined-attributes/{id} ' , $ content );
@@ -58,56 +58,32 @@ public function testGetJsonDocs(): void
58
58
$ this ->verifyVoidReturnType ('/test-void-return-type ' , $ content );
59
59
60
60
self ::assertArrayHasKey ('components ' , $ content );
61
-
62
- if (Kernel::VERSION_ID < 70000 ) {
63
- self ::assertSame ([
64
- 'schemas ' => [
65
- 'TestRequest ' => [
66
- 'properties ' => [
67
- 'id ' => [
68
- 'type ' => 'integer ' ,
69
- ],
70
- ],
71
- 'type ' => 'object ' ,
61
+ self ::assertSame ([
62
+ 'schemas ' => [
63
+ 'TestRequest ' => [
64
+ 'required ' => [
65
+ 'id ' ,
72
66
],
73
- 'TestResponse ' => [
74
- 'properties ' => [
75
- 'id ' => [
76
- 'type ' => 'integer ' ,
77
- ],
67
+ 'properties ' => [
68
+ 'id ' => [
69
+ 'type ' => 'integer ' ,
78
70
],
79
- 'type ' => 'object ' ,
80
71
],
72
+ 'type ' => 'object ' ,
81
73
],
82
- ], $ content ['components ' ]);
83
- } else {
84
- self ::assertSame ([
85
- 'schemas ' => [
86
- 'TestRequest ' => [
87
- 'required ' => [
88
- 'id ' ,
89
- ],
90
- 'properties ' => [
91
- 'id ' => [
92
- 'type ' => 'integer ' ,
93
- ],
94
- ],
95
- 'type ' => 'object ' ,
74
+ 'TestResponse ' => [
75
+ 'required ' => [
76
+ 'id ' ,
96
77
],
97
- 'TestResponse ' => [
98
- 'required ' => [
99
- 'id ' ,
100
- ],
101
- 'properties ' => [
102
- 'id ' => [
103
- 'type ' => 'integer ' ,
104
- ],
78
+ 'properties ' => [
79
+ 'id ' => [
80
+ 'type ' => 'integer ' ,
105
81
],
106
- 'type ' => 'object ' ,
107
82
],
83
+ 'type ' => 'object ' ,
108
84
],
109
- ], $ content [ ' components ' ]);
110
- }
85
+ ],
86
+ ], $ content [ ' components ' ]);
111
87
}
112
88
113
89
/**
@@ -260,6 +236,33 @@ private function verifyBuiltinReturnTypeRoute(string $path, array $content): voi
260
236
], $ content ['paths ' ][$ path ]['get ' ]['responses ' ]);
261
237
}
262
238
239
+ /**
240
+ * @param array<string, mixed> $content
241
+ */
242
+ private function verifyAnnotationGenericReturnTypeRoute (string $ path , array $ content ): void
243
+ {
244
+ $ this ->verifyTestRequestObjectQuery ($ path , $ content );
245
+
246
+ self ::assertArrayHasKey ('responses ' , $ content ['paths ' ][$ path ]['get ' ]);
247
+ self ::assertCount (1 , $ content ['paths ' ][$ path ]['get ' ]['responses ' ]);
248
+
249
+ self ::assertSame ([
250
+ 200 => [
251
+ 'description ' => 'get TestResponse collection ' ,
252
+ 'content ' => [
253
+ 'application/json ' => [
254
+ 'schema ' => [
255
+ 'type ' => 'array ' ,
256
+ 'items ' => [
257
+ '$ref ' => '#/components/schemas/TestResponse ' ,
258
+ ],
259
+ ],
260
+ ],
261
+ ],
262
+ ],
263
+ ], $ content ['paths ' ][$ path ]['get ' ]['responses ' ]);
264
+ }
265
+
263
266
/**
264
267
* @param array<string, mixed> $content
265
268
*/
0 commit comments