Skip to content

Commit bf29fb9

Browse files
fix(PropertyFilter): generated description isn't shown as parameter description in openapi (#5458)
1 parent a5aa529 commit bf29fb9

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

features/openapi/docs.feature

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Feature: Documentation support
7070
And the OpenAPI class "User-user_user-write" exists
7171
And the OpenAPI class "UuidIdentifierDummy" exists
7272
And the OpenAPI class "ThirdLevel" exists
73+
And the OpenAPI class "DummyCar" exists
7374
And the OpenAPI class "ParentDummy" doesn't exist
7475
And the OpenAPI class "UnknownDummy" doesn't exist
7576
And the OpenAPI path "/relation_embedders/{id}/custom" exists
@@ -112,6 +113,9 @@ Feature: Documentation support
112113
And the JSON node "paths./dummies.get.parameters[3].required" should be false
113114
And the JSON node "paths./dummies.get.parameters[3].schema.type" should be equal to "boolean"
114115

116+
And the JSON node "paths./dummy_cars.get.parameters[8].name" should be equal to "foobar[]"
117+
And the JSON node "paths./dummy_cars.get.parameters[8].description" should be equal to "Allows you to reduce the response to contain only the properties you need. If your desired property is nested, you can address it using nested arrays. Example: foobar[]={propertyName}&foobar[]={anotherPropertyName}&foobar[{nestedPropertyParent}][]={nestedProperty}"
118+
115119
# Subcollection - check filter on subResource
116120
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[0].name" should be equal to "id"
117121
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[0].in" should be equal to "path"

src/Serializer/Filter/PropertyFilter.php

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public function getDescription(string $resourceClass): array
7676
'type' => 'string',
7777
'is_collection' => true,
7878
'required' => false,
79+
'description' => 'Allows you to reduce the response to contain only the properties you need. If your desired property is nested, you can address it using nested arrays. Example: '.$example,
7980
'swagger' => [
8081
'description' => 'Allows you to reduce the response to contain only the properties you need. If your desired property is nested, you can address it using nested arrays. Example: '.$example,
8182
'name' => "$this->parameterName[]",

tests/Fixtures/TestBundle/Entity/DummyWithCollectDenormalizationErrors.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ public function getId(): ?int
6565
return $this->id;
6666
}
6767

68-
public function getFoo(): ?bool
69-
{
70-
return $this->foo;
71-
}
68+
public function getFoo(): ?bool
69+
{
70+
return $this->foo;
71+
}
7272

7373
public function setFoo(?bool $foo): void
7474
{

tests/Serializer/Filter/PropertyFilterTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ public function testGetDescription(): void
218218
'type' => 'string',
219219
'is_collection' => true,
220220
'required' => false,
221+
'description' => 'Allows you to reduce the response to contain only the properties you need. If your desired property is nested, you can address it using nested arrays. Example: custom_properties[]={propertyName}&custom_properties[]={anotherPropertyName}&custom_properties[{nestedPropertyParent}][]={nestedProperty}',
221222
'swagger' => [
222223
'description' => 'Allows you to reduce the response to contain only the properties you need. If your desired property is nested, you can address it using nested arrays. Example: custom_properties[]={propertyName}&custom_properties[]={anotherPropertyName}&custom_properties[{nestedPropertyParent}][]={nestedProperty}',
223224
'name' => 'custom_properties[]',

0 commit comments

Comments
 (0)