@@ -189,6 +189,7 @@ private function getPathOperation(string $operationName, array $operation, strin
189
189
private function updateGetOperation (\ArrayObject $ pathOperation , array $ mimeTypes , bool $ collection , ResourceMetadata $ resourceMetadata , string $ resourceClass , string $ resourceShortName , string $ operationName , \ArrayObject $ definitions )
190
190
{
191
191
$ responseDefinitionKey = $ this ->getDefinition ($ definitions , $ collection , false , $ resourceMetadata , $ resourceClass , $ operationName );
192
+
192
193
$ pathOperation ['produces ' ] ?? $ pathOperation ['produces ' ] = $ mimeTypes ;
193
194
194
195
if ($ collection ) {
@@ -203,7 +204,7 @@ private function updateGetOperation(\ArrayObject $pathOperation, array $mimeType
203
204
],
204
205
];
205
206
206
- if (!isset ($ pathOperation ['parameters ' ]) && count ($ parameters = $ this ->getFiltersParameters ($ resourceClass , $ operationName , $ resourceMetadata )) > 0 ) {
207
+ if (!isset ($ pathOperation ['parameters ' ]) && count ($ parameters = $ this ->getFiltersParameters ($ resourceClass , $ operationName , $ resourceMetadata, $ responseDefinitionKey )) > 0 ) {
207
208
$ pathOperation ['parameters ' ] = $ parameters ;
208
209
}
209
210
@@ -350,8 +351,7 @@ private function getDefinition(\ArrayObject $definitions, bool $collection, bool
350
351
} else {
351
352
$ definitionKey = $ resourceMetadata ->getShortName ();
352
353
}
353
-
354
- $ definitions [$ definitionKey ] = $ this ->getDefinitionSchema ($ resourceClass , $ resourceMetadata , $ serializerContext );
354
+ $ definitions [$ definitionKey ] = $ this ->getDefinitionSchema ($ resourceClass , $ resourceMetadata , $ serializerContext , $ definitionKey );
355
355
356
356
return $ definitionKey ;
357
357
}
@@ -369,7 +369,7 @@ private function getDefinition(\ArrayObject $definitions, bool $collection, bool
369
369
*
370
370
* @return \ArrayObject
371
371
*/
372
- private function getDefinitionSchema (string $ resourceClass , ResourceMetadata $ resourceMetadata , array $ serializerContext = null ): \ArrayObject
372
+ private function getDefinitionSchema (string $ resourceClass , ResourceMetadata $ resourceMetadata , array $ serializerContext = null , $ definitionKey = null ): \ArrayObject
373
373
{
374
374
$ definitionSchema = new \ArrayObject (['type ' => 'object ' ]);
375
375
@@ -390,7 +390,7 @@ private function getDefinitionSchema(string $resourceClass, ResourceMetadata $re
390
390
$ definitionSchema ['required ' ][] = $ normalizedPropertyName ;
391
391
}
392
392
393
- $ definitionSchema ['properties ' ][$ normalizedPropertyName ] = $ this ->getPropertySchema ($ propertyMetadata );
393
+ $ definitionSchema ['properties ' ][$ normalizedPropertyName ] = $ this ->getPropertySchema ($ propertyMetadata, $ definitionKey );
394
394
}
395
395
396
396
return $ definitionSchema ;
@@ -405,7 +405,7 @@ private function getDefinitionSchema(string $resourceClass, ResourceMetadata $re
405
405
*
406
406
* @return \ArrayObject
407
407
*/
408
- private function getPropertySchema (PropertyMetadata $ propertyMetadata ): \ArrayObject
408
+ private function getPropertySchema (PropertyMetadata $ propertyMetadata, $ definitionKey = null ): \ArrayObject
409
409
{
410
410
$ propertySchema = new \ArrayObject ();
411
411
@@ -430,7 +430,7 @@ private function getPropertySchema(PropertyMetadata $propertyMetadata): \ArrayOb
430
430
$ className = $ valueType ->getClassName ();
431
431
}
432
432
433
- $ valueSchema = $ this ->getType ($ builtinType , $ isCollection , $ className , $ propertyMetadata ->isReadableLink ());
433
+ $ valueSchema = $ this ->getType ($ builtinType , $ isCollection , $ className , $ propertyMetadata ->isReadableLink (), $ definitionKey );
434
434
435
435
return new \ArrayObject ((array ) $ propertySchema + $ valueSchema );
436
436
}
@@ -445,10 +445,10 @@ private function getPropertySchema(PropertyMetadata $propertyMetadata): \ArrayOb
445
445
*
446
446
* @return array
447
447
*/
448
- private function getType (string $ type , bool $ isCollection , string $ className = null , bool $ readableLink = null ): array
448
+ private function getType (string $ type , bool $ isCollection , string $ className = null , bool $ readableLink = null , $ definitionKey = null ): array
449
449
{
450
450
if ($ isCollection ) {
451
- return ['type ' => 'array ' , 'items ' => $ this ->getType ($ type , false , $ className , $ readableLink )];
451
+ return ['type ' => 'array ' , 'items ' => $ this ->getType ($ type , false , $ className , $ readableLink, $ definitionKey )];
452
452
}
453
453
454
454
if (Type::BUILTIN_TYPE_STRING === $ type ) {
@@ -481,7 +481,7 @@ private function getType(string $type, bool $isCollection, string $className = n
481
481
}
482
482
483
483
if (true === $ readableLink ) {
484
- return ['$ref ' => sprintf ('#/definitions/%s ' , $ this ->resourceMetadataFactory ->create ($ className )->getShortName ())];
484
+ return ['$ref ' => sprintf ('#/definitions/%s ' , $ definitionKey ?: $ this ->resourceMetadataFactory ->create ($ className )->getShortName ())];
485
485
}
486
486
}
487
487
@@ -529,7 +529,7 @@ private function computeDoc(Documentation $documentation, \ArrayObject $definiti
529
529
*
530
530
* @return array
531
531
*/
532
- private function getFiltersParameters (string $ resourceClass , string $ operationName , ResourceMetadata $ resourceMetadata ): array
532
+ private function getFiltersParameters (string $ resourceClass , string $ operationName , ResourceMetadata $ resourceMetadata, $ definitionKey ): array
533
533
{
534
534
if (null === $ this ->filterCollection ) {
535
535
return [];
@@ -548,7 +548,7 @@ private function getFiltersParameters(string $resourceClass, string $operationNa
548
548
'in ' => 'query ' ,
549
549
'required ' => $ data ['required ' ],
550
550
];
551
- $ parameter += $ this ->getType ($ data ['type ' ], false );
551
+ $ parameter += $ this ->getType ($ data ['type ' ], false , null , null , $ definitionKey );
552
552
553
553
if (isset ($ data ['swagger ' ])) {
554
554
$ parameter = $ data ['swagger ' ] + $ parameter ;
0 commit comments