File tree Expand file tree Collapse file tree 5 files changed +31
-3
lines changed
Expand file tree Collapse file tree 5 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,6 @@ public function getProduct(?int $product_id)
6868 * @OA\MediaType(
6969 * mediaType="application/json",
7070 * @OA\Schema(
71- * type="array",
7271 * @OA\Items(ref="#/components/schemas/Product")
7372 * )
7473 * )
Original file line number Diff line number Diff line change @@ -48,7 +48,6 @@ public function getProduct(
4848 content: [new OAT \MediaType (
4949 mediaType: 'application/json ' ,
5050 schema: new OAT \Schema (
51- type: 'array ' ,
5251 items: new OAT \Items (type: Product::class)
5352 )
5453 )]
Original file line number Diff line number Diff line change @@ -57,7 +57,6 @@ public function getProduct(?int $product_id)
5757 * description="New product",
5858 * required=true,
5959 * @OA\JsonContent(
60- * type="array",
6160 * @OA\Items(ref="#/components/schemas/Product")
6261 * )
6362 * )
Original file line number Diff line number Diff line change @@ -237,6 +237,7 @@ public function getProcessorPipeline(): Pipeline
237237 new Processors \BuildPaths (),
238238 new Processors \AugmentParameters (),
239239 new Processors \AugmentRefs (),
240+ new Processors \AugmentItems (),
240241 new Processors \MergeJsonContent (),
241242 new Processors \MergeXmlContent (),
242243 new Processors \AugmentMediaType (),
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ /**
4+ * @license Apache 2.0
5+ */
6+
7+ namespace OpenApi \Processors ;
8+
9+ use OpenApi \Analysis ;
10+ use OpenApi \Annotations as OA ;
11+ use OpenApi \Context ;
12+
13+ /**
14+ * Use the Schema context to extract useful information and inject that into the annotation.
15+ *
16+ * Merges properties.
17+ */
18+ class AugmentItems
19+ {
20+ public function __invoke (Analysis $ analysis ): void
21+ {
22+ $ schemas = $ analysis ->getAnnotationsOfType (OA \Schema::class);
23+
24+ foreach ($ schemas as $ schema ) {
25+ if ($ schema ->items instanceof OA \Items) {
26+ $ schema ->type = 'array ' ;
27+ }
28+ }
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments