Skip to content

Commit

Permalink
Merge pull request #97 from Menkveld-24/patch-1
Browse files Browse the repository at this point in the history
Fix collection merging bug
  • Loading branch information
andreaselia authored May 6, 2024
2 parents 9a83411 + 9525103 commit c4f0015
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Processors/RouteProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ protected function processRequest(string $method, Stringable $uri, Collection $r
]);

if ($method === 'GET') {
return $collection->put('url', [
'query' => $rules->map(fn ($value) => array_merge($value, ['disabled' => false])),
return $collection->mergeRecursive([
'url' => [
'query' => $rules->map(fn ($value) => array_merge($value, ['disabled' => false])),
],
]);
}

Expand Down
12 changes: 12 additions & 0 deletions tests/Feature/ExportPostmanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ public function test_rules_printing_get_export_works()
->where('name', 'example/getWithFormRequest')
->first();

$this->assertEqualsCanonicalizing([
'raw' => '{{base_url}}/example/getWithFormRequest',
'host' => [
'{{base_url}}',
],
'path' => [
'example',
'getWithFormRequest',
],
'variable' => [],
], array_slice($targetRequest['request']['url'], 0, 4));

$fields = collect($targetRequest['request']['url']['query']);
$this->assertCount(1, $fields->where('key', 'field_1')->where('description', 'required'));
$this->assertCount(1, $fields->where('key', 'field_2')->where('description', 'required, integer'));
Expand Down

0 comments on commit c4f0015

Please sign in to comment.