Skip to content

Commit d3b4b7b

Browse files
committed
Merge 4.1
2 parents b52187d + f3a54a2 commit d3b4b7b

File tree

26 files changed

+251
-34
lines changed

26 files changed

+251
-34
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
"symfony/serializer": "^6.4 || ^7.0",
117117
"symfony/translation-contracts": "^3.3",
118118
"symfony/type-info": "^7.3",
119+
"symfony/validator": "^6.4 || ^7.1",
119120
"symfony/web-link": "^6.4 || ^7.1",
120121
"willdurand/negotiation": "^3.1"
121122
},

features/openapi/docs.feature

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ Feature: Documentation support
107107
#And the "isDummyBoolean" property exists for the OpenAPI class "DummyBoolean"
108108
#And the "isDummyBoolean" property is not read only for the OpenAPI class "DummyBoolean"
109109
# Filters
110-
And the JSON node "paths./dummies.get.parameters[3].name" should be equal to "dummyBoolean"
111-
And the JSON node "paths./dummies.get.parameters[3].in" should be equal to "query"
112-
And the JSON node "paths./dummies.get.parameters[3].required" should be false
113-
And the JSON node "paths./dummies.get.parameters[3].schema.type" should be equal to "boolean"
110+
And the JSON node "paths./dummies.get.parameters[4].name" should be equal to "dummyBoolean"
111+
And the JSON node "paths./dummies.get.parameters[4].in" should be equal to "query"
112+
And the JSON node "paths./dummies.get.parameters[4].required" should be false
113+
And the JSON node "paths./dummies.get.parameters[4].schema.type" should be equal to "boolean"
114114

115-
And the JSON node "paths./dummy_cars.get.parameters[8].name" should be equal to "foobar[]"
116-
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}"
115+
And the JSON node "paths./dummy_cars.get.parameters[9].name" should be equal to "foobar[]"
116+
And the JSON node "paths./dummy_cars.get.parameters[9].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}"
117117

118118
# Webhook
119119
And the JSON node "webhooks.a.get.description" should be equal to "Something else here for example"
@@ -140,16 +140,16 @@ Feature: Documentation support
140140
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[3].required" should be false
141141
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[3].schema.type" should be equal to "boolean"
142142

143-
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[4].name" should be equal to "name"
144-
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[4].in" should be equal to "query"
145-
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[4].required" should be false
146-
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[4].schema.type" should be equal to "string"
147-
148-
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[5].name" should be equal to "description"
143+
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[5].name" should be equal to "name"
149144
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[5].in" should be equal to "query"
150145
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[5].required" should be false
146+
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[5].schema.type" should be equal to "string"
147+
148+
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[6].name" should be equal to "description"
149+
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[6].in" should be equal to "query"
150+
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters[6].required" should be false
151151

152-
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters" should have 6 elements
152+
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.parameters" should have 7 elements
153153

154154
# Subcollection - check schema
155155
And the JSON node "paths./related_dummies/{id}/related_to_dummy_friends.get.responses.200.content.application/ld+json.schema.allOf[1].properties.hydra:member.items.$ref" should be equal to "#/components/schemas/RelatedToDummyFriend.jsonld-fakemanytomany"

src/Doctrine/Common/CollectionPaginator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class CollectionPaginator implements \IteratorAggregate, PaginatorInterfac
3434
* @param ReadableCollection<array-key,T> $collection
3535
*/
3636
public function __construct(
37-
readonly ReadableCollection $collection,
37+
public readonly ReadableCollection $collection,
3838
private readonly float $currentPage,
3939
private readonly float $itemsPerPage,
4040
) {

src/Doctrine/Common/SelectablePaginator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class SelectablePaginator implements \IteratorAggregate, PaginatorInterfac
3636
* @param Selectable<array-key,T> $selectable
3737
*/
3838
public function __construct(
39-
readonly Selectable $selectable,
39+
public readonly Selectable $selectable,
4040
private readonly float $currentPage,
4141
private readonly float $itemsPerPage,
4242
) {

src/Doctrine/Common/SelectablePartialPaginator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class SelectablePartialPaginator implements \IteratorAggregate, PartialPag
3535
* @param Selectable<array-key,T> $selectable
3636
*/
3737
public function __construct(
38-
readonly Selectable $selectable,
38+
public readonly Selectable $selectable,
3939
private readonly float $currentPage,
4040
private readonly float $itemsPerPage,
4141
) {

src/Hydra/Serializer/CollectionFiltersNormalizer.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,20 @@ private function getSearch(string $resourceClass, array $parts, array $filters,
152152
continue;
153153
}
154154

155-
if (($prop = $parameter->getProperty()) && ($description['property'] ?? null) !== $prop) {
155+
if (!($descriptionProperty = $description['property'] ?? null)) {
156+
continue;
157+
}
158+
159+
if (($prop = $parameter->getProperty()) && $descriptionProperty !== $prop) {
156160
continue;
157161
}
158162

159163
// :property is a pattern allowed when defining parameters
160-
$k = str_replace(':property', $description['property'], $key);
161-
$variable = str_replace($description['property'], $k, $variable);
164+
$k = str_replace(':property', $descriptionProperty, $key);
165+
$variable = str_replace($descriptionProperty, $k, $variable);
162166
$variables[] = $variable;
163-
$m = ['@type' => 'IriTemplateMapping', 'variable' => $variable, 'property' => $description['property'], 'required' => $description['required']];
164-
if (null !== ($required = $parameter->getRequired())) {
167+
$m = ['@type' => 'IriTemplateMapping', 'variable' => $variable, 'property' => $descriptionProperty];
168+
if (null !== ($required = $parameter->getRequired() ?? $description['required'] ?? null)) {
165169
$m['required'] = $required;
166170
}
167171
$mapping[] = $m;

src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFactory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,17 @@ private function getDocBlock(string $class): ?PhpDocNode
126126
return $this->docBlocks[$class];
127127
}
128128

129+
if (!$this->phpDocParser || !$this->lexer) {
130+
return null;
131+
}
132+
129133
try {
130134
$reflectionClass = new \ReflectionClass($class);
131135
} catch (\ReflectionException) {
132136
return null;
133137
}
134138

135139
$rawDocNode = $reflectionClass->getDocComment();
136-
137140
if (!$rawDocNode) {
138141
return null;
139142
}

src/OpenApi/Factory/OpenApiFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,10 @@ private function getPaginationParameters(CollectionOperationInterface|HttpOperat
845845
);
846846
}
847847

848+
if ($operation->getPaginationClientPartial() ?? $this->paginationOptions->isClientPartialPaginationEnabled()) {
849+
$parameters[] = new Parameter($this->paginationOptions->getPartialPaginationParameterName(), 'query', 'Enable or disable partial pagination', false, false, true, ['type' => 'boolean']);
850+
}
851+
848852
return $parameters;
849853
}
850854

src/OpenApi/Tests/Factory/OpenApiFactoryTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public function testInvoke(): void
181181
'paginatedDummyCollection' => (new GetCollection())->withUriTemplate('/paginated')
182182
->withPaginationClientEnabled(true)
183183
->withPaginationClientItemsPerPage(true)
184+
->withPaginationClientPartial(true)
184185
->withPaginationItemsPerPage(20)
185186
->withPaginationMaximumItemsPerPage(80)
186187
->withOperation($baseOperation),
@@ -992,6 +993,9 @@ public function testInvoke(): void
992993
new Parameter('pagination', 'query', 'Enable or disable pagination', false, false, null, [
993994
'type' => 'boolean',
994995
]),
996+
new Parameter('partial', 'query', 'Enable or disable partial pagination', false, false, true, [
997+
'type' => 'boolean',
998+
]),
995999
]
9961000
), $paginatedPath->getGet());
9971001

src/State/ApiResource/Error.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
routeName: '_api_errors',
3939
outputFormats: [
4040
'json' => ['application/problem+json', 'application/json'],
41-
'xml' => ['application/xml', 'text/xml'],
4241
],
4342
hideHydraOperation: true,
4443
normalizationContext: [
@@ -75,6 +74,21 @@
7574
'ignored_attributes' => ['trace', 'file', 'line', 'code', 'message', 'traceAsString', 'previous'],
7675
],
7776
),
77+
new Operation(
78+
errors: [],
79+
name: '_api_errors_xml',
80+
routeName: '_api_errors',
81+
outputFormats: [
82+
'xml' => ['application/xml', 'text/xml'],
83+
],
84+
hideHydraOperation: true,
85+
normalizationContext: [
86+
SchemaFactory::OPENAPI_DEFINITION_NAME => '',
87+
'groups' => ['jsonproblem'],
88+
'skip_null_values' => true,
89+
'ignored_attributes' => ['trace', 'file', 'line', 'code', 'message', 'traceAsString', 'previous'],
90+
],
91+
),
7892
new Operation(
7993
name: '_api_errors',
8094
hideHydraOperation: true,

0 commit comments

Comments
 (0)