Skip to content

Commit 2cde062

Browse files
authored
fix(openapi): output partial query parameter to OpenAPI when pagination_client_enabled is true (#7295)
1 parent 2c06a22 commit 2cde062

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

features/openapi/docs.feature

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

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

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

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

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

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

src/OpenApi/Factory/OpenApiFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,10 @@ private function getPaginationParameters(CollectionOperationInterface|HttpOperat
755755
$parameters[] = new Parameter($this->paginationOptions->getPaginationClientEnabledParameterName(), 'query', 'Enable or disable pagination', false, false, true, ['type' => 'boolean']);
756756
}
757757

758+
if ($operation->getPaginationClientPartial() ?? $this->paginationOptions->isClientPartialPaginationEnabled()) {
759+
$parameters[] = new Parameter($this->paginationOptions->getPartialPaginationParameterName(), 'query', 'Enable or disable partial pagination', false, false, true, ['type' => 'boolean']);
760+
}
761+
758762
return $parameters;
759763
}
760764

src/OpenApi/Tests/Factory/OpenApiFactoryTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public function testInvoke(): void
182182
'paginatedDummyCollection' => (new GetCollection())->withUriTemplate('/paginated')
183183
->withPaginationClientEnabled(true)
184184
->withPaginationClientItemsPerPage(true)
185+
->withPaginationClientPartial(true)
185186
->withPaginationItemsPerPage(20)
186187
->withPaginationMaximumItemsPerPage(80)
187188
->withOperation($baseOperation),
@@ -994,6 +995,9 @@ public function testInvoke(): void
994995
new Parameter('pagination', 'query', 'Enable or disable pagination', false, false, true, [
995996
'type' => 'boolean',
996997
]),
998+
new Parameter('partial', 'query', 'Enable or disable partial pagination', false, false, true, [
999+
'type' => 'boolean',
1000+
]),
9971001
]
9981002
), $paginatedPath->getGet());
9991003

0 commit comments

Comments
 (0)