@@ -38,6 +38,7 @@ final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareI
3838
3939 private const ITEM_BASE_SCHEMA_NAME = 'HydraItemBaseSchema ' ;
4040 private const ITEM_WITHOUT_ID_BASE_SCHEMA_NAME = 'HydraItemBaseSchemaWithoutId ' ;
41+ private const COLLECTION_BASE_SCHEMA_NAME_NO_PAGINATION = 'HydraCollectionBaseSchemaNoPagination ' ;
4142 private const COLLECTION_BASE_SCHEMA_NAME = 'HydraCollectionBaseSchema ' ;
4243
4344 private const BASE_PROP = [
@@ -155,7 +156,7 @@ public function buildSchema(string $className, string $format = 'jsonld', string
155156
156157 $ hydraPrefix = $ this ->getHydraPrefix ($ serializerContext + $ this ->defaultContext );
157158
158- if (!isset ($ definitions [self ::COLLECTION_BASE_SCHEMA_NAME ])) {
159+ if (!isset ($ definitions [self ::COLLECTION_BASE_SCHEMA_NAME_NO_PAGINATION ])) {
159160 switch ($ schema ->getVersion ()) {
160161 // JSON Schema + OpenAPI 3.1
161162 case Schema::VERSION_OPENAPI :
@@ -168,49 +169,13 @@ public function buildSchema(string $className, string $format = 'jsonld', string
168169 break ;
169170 }
170171
171- $ definitions [self ::COLLECTION_BASE_SCHEMA_NAME ] = [
172+ $ definitions [self ::COLLECTION_BASE_SCHEMA_NAME_NO_PAGINATION ] = [
172173 'type ' => 'object ' ,
173174 'properties ' => [
174175 $ hydraPrefix .'totalItems ' => [
175176 'type ' => 'integer ' ,
176177 'minimum ' => 0 ,
177178 ],
178- $ hydraPrefix .'view ' => [
179- 'type ' => 'object ' ,
180- 'properties ' => [
181- '@id ' => [
182- 'type ' => 'string ' ,
183- 'format ' => 'iri-reference ' ,
184- ],
185- '@type ' => [
186- 'type ' => 'string ' ,
187- ],
188- $ hydraPrefix .'first ' => [
189- 'type ' => 'string ' ,
190- 'format ' => 'iri-reference ' ,
191- ],
192- $ hydraPrefix .'last ' => [
193- 'type ' => 'string ' ,
194- 'format ' => 'iri-reference ' ,
195- ],
196- $ hydraPrefix .'previous ' => [
197- 'type ' => 'string ' ,
198- 'format ' => 'iri-reference ' ,
199- ],
200- $ hydraPrefix .'next ' => [
201- 'type ' => 'string ' ,
202- 'format ' => 'iri-reference ' ,
203- ],
204- ],
205- 'example ' => [
206- '@id ' => 'string ' ,
207- 'type ' => 'string ' ,
208- $ hydraPrefix .'first ' => 'string ' ,
209- $ hydraPrefix .'last ' => 'string ' ,
210- $ hydraPrefix .'previous ' => 'string ' ,
211- $ hydraPrefix .'next ' => 'string ' ,
212- ],
213- ],
214179 $ hydraPrefix .'search ' => [
215180 'type ' => 'object ' ,
216181 'properties ' => [
@@ -233,13 +198,60 @@ public function buildSchema(string $className, string $format = 'jsonld', string
233198 ],
234199 ],
235200 ];
201+
202+ $ definitions [self ::COLLECTION_BASE_SCHEMA_NAME ] = [
203+ 'allOf ' => [
204+ ['$ref ' => $ prefix .self ::COLLECTION_BASE_SCHEMA_NAME_NO_PAGINATION ],
205+ [
206+ 'type ' => 'object ' ,
207+ 'properties ' => [
208+ $ hydraPrefix .'view ' => [
209+ 'type ' => 'object ' ,
210+ 'properties ' => [
211+ '@id ' => [
212+ 'type ' => 'string ' ,
213+ 'format ' => 'iri-reference ' ,
214+ ],
215+ '@type ' => [
216+ 'type ' => 'string ' ,
217+ ],
218+ $ hydraPrefix .'first ' => [
219+ 'type ' => 'string ' ,
220+ 'format ' => 'iri-reference ' ,
221+ ],
222+ $ hydraPrefix .'last ' => [
223+ 'type ' => 'string ' ,
224+ 'format ' => 'iri-reference ' ,
225+ ],
226+ $ hydraPrefix .'previous ' => [
227+ 'type ' => 'string ' ,
228+ 'format ' => 'iri-reference ' ,
229+ ],
230+ $ hydraPrefix .'next ' => [
231+ 'type ' => 'string ' ,
232+ 'format ' => 'iri-reference ' ,
233+ ],
234+ ],
235+ 'example ' => [
236+ '@id ' => 'string ' ,
237+ 'type ' => 'string ' ,
238+ $ hydraPrefix .'first ' => 'string ' ,
239+ $ hydraPrefix .'last ' => 'string ' ,
240+ $ hydraPrefix .'previous ' => 'string ' ,
241+ $ hydraPrefix .'next ' => 'string ' ,
242+ ],
243+ ],
244+ ],
245+ ],
246+ ],
247+ ];
236248 }
237249
238250 $ definitionName = $ this ->definitionNameFactory ->create ($ className , $ format , $ inputOrOutputClass , $ operation , $ serializerContext );
239251 $ schema ['type ' ] = 'object ' ;
240252 $ schema ['description ' ] = "$ definitionName collection. " ;
241253 $ schema ['allOf ' ] = [
242- ['$ref ' => $ prefix .self ::COLLECTION_BASE_SCHEMA_NAME ],
254+ ['$ref ' => $ prefix .( false === $ operation -> getPaginationEnabled () ? self ::COLLECTION_BASE_SCHEMA_NAME_NO_PAGINATION : self :: COLLECTION_BASE_SCHEMA_NAME ) ],
243255 [
244256 'type ' => 'object ' ,
245257 'required ' => [
0 commit comments