Skip to content

Commit 246031b

Browse files
fix test
1 parent d0e6d64 commit 246031b

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

src/LaravelRequestDocsToOpenApi.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ protected function attributeIsFile(string $rule): bool
8888
return str_contains($rule, 'file') || str_contains($rule, 'image');
8989
}
9090

91-
protected function makeQueryParameterItem(string $attribute, string $rule): array
91+
protected function makeQueryParameterItem(string $attribute, $rule): array
9292
{
93+
if (is_array($rule)) {
94+
$rule = implode('|', $rule);
95+
}
9396
$parameter = [
9497
'name' => $attribute,
9598
'description' => $rule,

tests/Controllers/LaravelRequestDocsControllerTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public function testPath()
408408
->assertStatus(Response::HTTP_OK);
409409

410410
$expected = [
411-
'id' => 'integer|required|regex:/[0-9]+/',
411+
'id' => ['integer|required|regex:/[0-9]+/'],
412412
];
413413

414414
$docs = collect($response->json());
@@ -429,7 +429,7 @@ public function testPathWithOptional()
429429
->assertStatus(Response::HTTP_OK);
430430

431431
$expected = [
432-
'name' => 'string|nullable|regex:/[A-Za-z]+/',
432+
'name' => ['string|nullable|regex:/[A-Za-z]+/'],
433433
];
434434

435435
$docs = collect($response->json());
@@ -449,9 +449,9 @@ public function testPathWithModelBinding()
449449
->assertStatus(Response::HTTP_OK);
450450

451451
$expected = [
452-
'user' => 'integer|required',
453-
'post' => 'string|required',
454-
'comment:name' => 'string|required',
452+
'user' => ['integer|required'],
453+
'post' => ['string|required'],
454+
'comment:name' => ['string|required'],
455455
];
456456

457457
$docs = collect($response->json());
@@ -473,9 +473,9 @@ public function testPathWithMethodParametersIsLesser()
473473
->assertStatus(Response::HTTP_OK);
474474

475475
$expected = [
476-
'id' => 'integer|required',
477-
'user' => 'string|required',
478-
'valid' => 'string|nullable|regex:/[A-Za-z]+/',
476+
'id' => ['integer|required'],
477+
'user' => ['string|required'],
478+
'valid' => ['string|nullable|regex:/[A-Za-z]+/'],
479479
];
480480

481481
$docs = collect($response->json());
@@ -499,7 +499,7 @@ public function testPathWithGlobalPattern()
499499
->assertStatus(Response::HTTP_OK);
500500

501501
$expected = [
502-
'id' => 'string|required|regex:/[0-9]+/',
502+
'id' => ['string|required|regex:/[0-9]+/'],
503503
];
504504

505505
$docs = collect($response->json());

tests/mocks/lrd-response.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
"method": "show",
176176
"http_method": "GET",
177177
"path_parameters": {
178-
"id": "string|required"
178+
"id": ["string|required"]
179179
},
180180
"rules": [],
181181
"doc_block": "",
@@ -200,7 +200,7 @@
200200
"method": "show",
201201
"http_method": "HEAD",
202202
"path_parameters": {
203-
"id": "string|required"
203+
"id": ["string|required"]
204204
},
205205
"rules": [],
206206
"doc_block": "",
@@ -557,7 +557,7 @@
557557
"method": "show",
558558
"http_method": "GET",
559559
"path_parameters": {
560-
"account": "string|required"
560+
"account": ["string|required"]
561561
},
562562
"rules": [],
563563
"doc_block": "",
@@ -582,7 +582,7 @@
582582
"method": "show",
583583
"http_method": "HEAD",
584584
"path_parameters": {
585-
"account": "string|required"
585+
"account": ["string|required"]
586586
},
587587
"rules": [],
588588
"doc_block": "",
@@ -607,7 +607,7 @@
607607
"method": "update",
608608
"http_method": "PUT",
609609
"path_parameters": {
610-
"account": "string|required"
610+
"account": ["string|required"]
611611
},
612612
"rules": [],
613613
"doc_block": "",
@@ -632,7 +632,7 @@
632632
"method": "update",
633633
"http_method": "PATCH",
634634
"path_parameters": {
635-
"account": "string|required"
635+
"account": ["string|required"]
636636
},
637637
"rules": [],
638638
"doc_block": "",
@@ -657,7 +657,7 @@
657657
"method": "destroy",
658658
"http_method": "DELETE",
659659
"path_parameters": {
660-
"account": "string|required"
660+
"account": ["string|required"]
661661
},
662662
"rules": [],
663663
"doc_block": "",

0 commit comments

Comments
 (0)