Skip to content

Commit

Permalink
OpenApi definitions have higher priority than core definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar authored and Milan Felix 艩ulc committed Mar 29, 2019
1 parent 4028d22 commit b0a8756
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/SchemaDefinition/CoreDefinition.php
Expand Up @@ -30,7 +30,7 @@ public function load(): array
foreach ($endpoint->getMethods() as $method) {
$data['paths'][(string) $endpoint->getMask()][strtolower($method)] = $this->createOperation($endpoint);
}
$data = Helpers::merge($data, $endpoint->getOpenApi()['controller'] ?? []);
$data = Helpers::merge($endpoint->getOpenApi()['controller'] ?? [], $data);
}
return $data;
}
Expand Down Expand Up @@ -75,7 +75,7 @@ protected function createOperation(Endpoint $endpoint): array
// TODO deprecated
// $operation->setDeprecated(false);

$operation = Helpers::merge($operation, $endpoint->getOpenApi()['method'] ?? []);
$operation = Helpers::merge($endpoint->getOpenApi()['method'] ?? [], $operation);

return $operation;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/SchemaDefinition/CoreDefinition.phpt
Expand Up @@ -44,7 +44,7 @@ final class CoreDefinitionTest extends TestCase
],
],
'method' => [
'description' => 'Not overridden description',
'description' => 'Overridden description',
],
]);

Expand All @@ -70,13 +70,12 @@ final class CoreDefinitionTest extends TestCase

Assert::same(
[
'info' => ['title' => 'Title', 'version' => '1.0.0'],
'paths' => [
'/foo/bar' => [
'get' => ['responses' => [], 'tags' => ['tag1']],
'post' => [
'description' => 'description',
'responses' => [200 => ['description' => 'description']],
'description' => 'Overridden description',
'tags' => ['tag2', 'tag3'],
'parameters' => [
[
Expand All @@ -96,8 +95,8 @@ final class CoreDefinitionTest extends TestCase
],
],
'put' => [
'description' => 'description',
'responses' => [200 => ['description' => 'description']],
'description' => 'Overridden description',
'tags' => ['tag2', 'tag3'],
'parameters' => [
[
Expand All @@ -118,6 +117,7 @@ final class CoreDefinitionTest extends TestCase
],
],
],
'info' => ['title' => 'Title', 'version' => '1.0.0'],
],
$definition->load()
);
Expand Down

0 comments on commit b0a8756

Please sign in to comment.