diff --git a/config/services.xml b/config/services.xml index 93c4515d6..55db81ba3 100644 --- a/config/services.xml +++ b/config/services.xml @@ -96,14 +96,6 @@ - - - - - - - - diff --git a/src/ModelDescriber/DateTimeModelDescriber.php b/src/ModelDescriber/DateTimeModelDescriber.php deleted file mode 100644 index 8e8e2397a..000000000 --- a/src/ModelDescriber/DateTimeModelDescriber.php +++ /dev/null @@ -1,31 +0,0 @@ -type = 'string'; - $schema->format = 'date-time'; - } - - public function supports(Model $model): bool - { - return Type::BUILTIN_TYPE_OBJECT === $model->getType()->getBuiltinType() - && is_a($model->getType()->getClassName(), \DateTimeInterface::class, true); - } -} diff --git a/src/ModelDescriber/UuidModelDescriber.php b/src/ModelDescriber/UuidModelDescriber.php deleted file mode 100644 index c712177cd..000000000 --- a/src/ModelDescriber/UuidModelDescriber.php +++ /dev/null @@ -1,32 +0,0 @@ -type = 'string'; - $schema->format = 'uuid'; - } - - public function supports(Model $model): bool - { - return Type::BUILTIN_TYPE_OBJECT === $model->getType()->getBuiltinType() - && is_a($model->getType()->getClassName(), AbstractUid::class, true); - } -} diff --git a/src/SchemaDescriber/ObjectClassDescriber.php b/src/SchemaDescriber/ObjectClassDescriber.php index 5d7f73745..de3b64f57 100644 --- a/src/SchemaDescriber/ObjectClassDescriber.php +++ b/src/SchemaDescriber/ObjectClassDescriber.php @@ -19,6 +19,7 @@ use Symfony\Component\TypeInfo\Type; use Symfony\Component\TypeInfo\Type\ObjectType; use Symfony\Component\TypeInfo\TypeIdentifier; +use Symfony\Component\Uid\AbstractUid; /** * @implements SchemaDescriberInterface @@ -31,6 +32,20 @@ final class ObjectClassDescriber implements SchemaDescriberInterface, ModelRegis public function describe(Type $type, Schema $schema, array $context = []): void { + if (is_a($type->getClassName(), AbstractUid::class, true)) { + $schema->type = 'string'; + $schema->format = 'uuid'; + + return; + } + + if (is_a($type->getClassName(), \DateTimeInterface::class, true)) { + $schema->type = 'string'; + $schema->format = 'date-time'; + + return; + } + $schema->ref = $this->modelRegistry->register( new Model(new LegacyType('object', false, $type->getClassName()), null, null, $context) );