From c07abe0fd4eece7e6d4e99e8f0609ee10a1fd231 Mon Sep 17 00:00:00 2001 From: DjordyKoert Date: Tue, 2 Jan 2024 23:38:54 +0100 Subject: [PATCH] re-add manually iterating over describers --- .../SymfonyMapQueryStringDescriber.php | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/RouteDescriber/InlineParameterDescriber/SymfonyMapQueryStringDescriber.php b/RouteDescriber/InlineParameterDescriber/SymfonyMapQueryStringDescriber.php index bb7fab038..9d34fe6f8 100644 --- a/RouteDescriber/InlineParameterDescriber/SymfonyMapQueryStringDescriber.php +++ b/RouteDescriber/InlineParameterDescriber/SymfonyMapQueryStringDescriber.php @@ -7,6 +7,7 @@ use Nelmio\ApiDocBundle\Describer\ModelRegistryAwareInterface; use Nelmio\ApiDocBundle\Describer\ModelRegistryAwareTrait; use Nelmio\ApiDocBundle\Model\Model; +use Nelmio\ApiDocBundle\ModelDescriber\ModelDescriberInterface; use Nelmio\ApiDocBundle\OpenApiPhp\Util; use OpenApi\Annotations as OA; use OpenApi\Generator; @@ -18,6 +19,14 @@ final class SymfonyMapQueryStringDescriber implements InlineParameterDescriberIn { use ModelRegistryAwareTrait; + /** + * @param ModelDescriberInterface[] $modelDescribers + */ + public function __construct( + private iterable $modelDescribers + ) { + } + public function supports(ArgumentMetadata $argumentMetadata): bool { if (!$argumentMetadata->getAttributes(MapQueryString::class, ArgumentMetadata::IS_INSTANCEOF)) { @@ -32,12 +41,23 @@ public function describe(OA\OpenApi $api, OA\Operation $operation, ArgumentMetad $model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, $argumentMetadata->isNullable(), $argumentMetadata->getType())); $modelRef = $this->modelRegistry->register($model); - $this->modelRegistry->registerSchemas($model->getHash()); $nativeModelName = str_replace(OA\Components::SCHEMA_REF, '', $modelRef); $schemaModel = Util::getSchema($api, $nativeModelName); + foreach ($this->modelDescribers as $modelDescriber) { + if ($modelDescriber instanceof ModelRegistryAwareInterface) { + $modelDescriber->setModelRegistry($this->modelRegistry); + } + + if ($modelDescriber->supports($model)) { + $modelDescriber->describe($model, $schemaModel); + + break; + } + } + // There are no properties to map to query parameters if (Generator::UNDEFINED === $schemaModel->properties) { return;