Skip to content

Commit

Permalink
fix(elasticsearch): add is_collection to documentation (#5497)
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvw authored Apr 4, 2023
1 parent 43394b4 commit 2586134
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Elasticsearch/Filter/AbstractSearchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public function getDescription(string $resourceClass): array
'property' => $property,
'type' => $hasAssociation ? 'string' : $this->getPhpType($type),
'required' => false,
'is_collection' => str_ends_with((string) $filterParameterName, '[]'),
];
}
}
Expand Down
8 changes: 8 additions & 0 deletions tests/Elasticsearch/Filter/MatchFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,41 +176,49 @@ public function testGetDescription(): void
'property' => 'id',
'type' => 'int',
'required' => false,
'is_collection' => false,
],
'id[]' => [
'property' => 'id',
'type' => 'int',
'required' => false,
'is_collection' => true,
],
'name' => [
'property' => 'name',
'type' => 'string',
'required' => false,
'is_collection' => false,
],
'name[]' => [
'property' => 'name',
'type' => 'string',
'required' => false,
'is_collection' => true,
],
'date' => [
'property' => 'date',
'type' => \DateTimeInterface::class,
'required' => false,
'is_collection' => false,
],
'date[]' => [
'property' => 'date',
'type' => \DateTimeInterface::class,
'required' => false,
'is_collection' => true,
],
'weird' => [
'property' => 'weird',
'type' => 'string',
'required' => false,
'is_collection' => false,
],
'weird[]' => [
'property' => 'weird',
'type' => 'string',
'required' => false,
'is_collection' => true,
],
],
$matchFilter->getDescription(Foo::class)
Expand Down
8 changes: 8 additions & 0 deletions tests/Elasticsearch/Filter/TermFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,41 +176,49 @@ public function testGetDescription(): void
'property' => 'id',
'type' => 'int',
'required' => false,
'is_collection' => false,
],
'id[]' => [
'property' => 'id',
'type' => 'int',
'required' => false,
'is_collection' => true,
],
'name' => [
'property' => 'name',
'type' => 'string',
'required' => false,
'is_collection' => false,
],
'name[]' => [
'property' => 'name',
'type' => 'string',
'required' => false,
'is_collection' => true,
],
'date' => [
'property' => 'date',
'type' => \DateTimeInterface::class,
'required' => false,
'is_collection' => false,
],
'date[]' => [
'property' => 'date',
'type' => \DateTimeInterface::class,
'required' => false,
'is_collection' => true,
],
'weird' => [
'property' => 'weird',
'type' => 'string',
'required' => false,
'is_collection' => false,
],
'weird[]' => [
'property' => 'weird',
'type' => 'string',
'required' => false,
'is_collection' => true,
],
],
$termFilter->getDescription(Foo::class)
Expand Down

0 comments on commit 2586134

Please sign in to comment.