Skip to content

Commit

Permalink
Fix bug and updated tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevhenii Vaskevych committed Apr 4, 2019
1 parent 89581f5 commit 1f6dd4c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Config/ConfigParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ private function iterate(array $config): array
$path = $this->configFolder.$nestedPath;

if (\is_dir($path)) {
$config[$key] = [];
$config[$key] += $this->parseDir($path);
$config[$key] = $this->parseDir($path);
} else if(\is_file($path)) {
$config[$key] = $this->parseFile($path);
} else {
Expand Down Expand Up @@ -81,6 +80,7 @@ private function parseDir(string $dirPath): array
{
$finder = new Finder();
$finder
->depth('<=1')
->files()
->in($dirPath)
->sortByName()
Expand All @@ -90,7 +90,7 @@ private function parseDir(string $dirPath): array
$nestedDirs = [];
if ($finder->hasResults()) {
foreach ($finder as $file) {
$nestedDirs += Yaml::parseFile($file->getPathname());
$nestedDirs = \array_replace_recursive($nestedDirs, Yaml::parseFile($file->getPathname()));
}
}

Expand Down
8 changes: 6 additions & 2 deletions tests/Config/ConfigParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ public function testParse(): void
],
],
],
'get' => [
'operationId' => 'GetOrderList',
'summary' => 'Get orders list',
],
],
'/users' => [
'post' => [
'operationId' => 'CreateUser',
'summary' => 'Create User',
'responses' => [
'201' => [
'description' => '201 response'
]
'description' => '201 response',
],
],
],
],
Expand Down
4 changes: 4 additions & 0 deletions tests/Config/Fixtures/api/paths/order/get-order-list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"/orders":
get:
operationId: GetOrderList
summary: Get orders list

0 comments on commit 1f6dd4c

Please sign in to comment.