Skip to content

Commit 19fc20d

Browse files
authored
Merge pull request #1947 from mab05k/bugfix/subresource-filters
Subresource Filter Fix
2 parents e91f362 + ec61304 commit 19fc20d

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

features/main/relation.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Feature: Relations support
9797
"@id": "/related_to_dummy_friends/dummyFriend=1;relatedDummy=1",
9898
"@type": "RelatedToDummyFriend",
9999
"name": "Friends relation",
100+
"description": null,
100101
"dummyFriend": {
101102
"@id": "/dummy_friends/1",
102103
"@type": "DummyFriend",
@@ -117,6 +118,7 @@ Feature: Relations support
117118
"@id": "/related_to_dummy_friends/dummyFriend=1;relatedDummy=1",
118119
"@type": "RelatedToDummyFriend",
119120
"name": "Friends relation",
121+
"description": null,
120122
"dummyFriend": {
121123
"@id": "/dummy_friends/1",
122124
"@type": "DummyFriend",

features/swagger/docs.feature

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ Feature: Documentation support
6969
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[1].in" should be equal to "query"
7070
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[1].required" should be false
7171
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[1].type" should be equal to "string"
72-
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters" should have 2 element
72+
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[2].name" should be equal to "description"
73+
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[2].in" should be equal to "query"
74+
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[2].required" should be false
75+
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[2].type" should be equal to "string"
76+
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters" should have 3 element
7377

7478
# Subcollection - check schema
7579
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.responses.200.schema.items.$ref" should be equal to "#/definitions/RelatedToDummyFriend-fakemanytomany"

src/Swagger/Serializer/DocumentationNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public function normalize($object, $format = null, array $context = [])
154154
}
155155
}
156156

157-
if ($parameters = $this->getFiltersParameters($resourceClass, $operationName, $subResourceMetadata, $definitions, $serializerContext)) {
157+
if ($parameters = $this->getFiltersParameters($subresourceOperation['resource_class'], $operationName, $subResourceMetadata, $definitions, $serializerContext)) {
158158
foreach ($parameters as $parameter) {
159159
if (!\in_array($parameter['name'], $parametersMemory, true)) {
160160
$pathOperation['parameters'][] = $parameter;

tests/Fixtures/TestBundle/Entity/RelatedToDummyFriend.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ class RelatedToDummyFriend
3737
*/
3838
private $name;
3939

40+
/**
41+
* @var string|null The dummy description
42+
*
43+
* @ORM\Column(nullable=true)
44+
* @Groups({"fakemanytomany", "friends"})
45+
*/
46+
private $description;
47+
4048
/**
4149
* @ORM\Id
4250
* @ORM\ManyToOne(targetEntity="DummyFriend")
@@ -64,6 +72,22 @@ public function getName()
6472
return $this->name;
6573
}
6674

75+
/**
76+
* @return null|string
77+
*/
78+
public function getDescription()
79+
{
80+
return $this->description;
81+
}
82+
83+
/**
84+
* @param null|string $description
85+
*/
86+
public function setDescription($description)
87+
{
88+
$this->description = $description;
89+
}
90+
6791
/**
6892
* Gets dummyFriend.
6993
*

tests/Fixtures/app/config/config_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ services:
204204

205205
app.related_dummy_to_friend_resource.search_filter:
206206
parent: 'api_platform.doctrine.orm.search_filter'
207-
arguments: [ { 'name': 'ipartial' } ]
207+
arguments: [ { 'name': 'ipartial', 'description': 'ipartial' } ]
208208
tags: [ { name: 'api_platform.filter', id: 'related_to_dummy_friend.name' } ]
209209

210210
logger:

0 commit comments

Comments
 (0)