API Platform version(s) affected: 3.2.1
Description
In 3.1 decorating the service api_platform.json_schema.type_factory works for customising the json schema type for a custom userland class.
How to reproduce
Here, I decorate the type factory to add support for using Brick\DateTime\LocalDate as a date
<?php
declare(strict_types=1);
namespace App\ApiResource;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use Brick\DateTime\LocalDate;
#[ApiResource(
operations: [
new Get(),
],
)]
class Foo
{
#[ApiProperty(readable: false, writable: false, identifier: true)]
public ?int $id = null;
public ?LocalDate $expiration;
}
<?php
declare(strict_types=1);
namespace App\ApiPlatform;
use ApiPlatform\JsonSchema\Schema;
use ApiPlatform\JsonSchema\TypeFactoryInterface;
use Brick\DateTime\LocalDate;
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
use Symfony\Component\PropertyInfo\Type;
#[AsDecorator('api_platform.json_schema.type_factory')]
class TypeFactoryDecorator implements TypeFactoryInterface
{
public function __construct(
private readonly TypeFactoryInterface $decorated,
) {
}
/** @phpstan-ignore-next-line */
public function getType(Type $type, string $format = 'json', ?bool $readableLink = null, ?array $serializerContext = null, ?Schema $schema = null): array
{
/** @phpstan-ignore-next-line */
if (\is_a($type->getClassName(), LocalDate::class, true)) {
return [
'type' => 'string',
'format' => 'date',
];
}
return $this->decorated->getType($type, $format, $readableLink, $serializerContext, $schema);
}
}
in 3.1, the schemas are correct:
in 3.2, they are not:

Possible Solution
Unsure, tried to figure it out but failed.
Additional Context
API Platform version(s) affected: 3.2.1
Description
In 3.1 decorating the service
api_platform.json_schema.type_factoryworks for customising the json schema type for a custom userland class.How to reproduce
Here, I decorate the type factory to add support for using Brick\DateTime\LocalDate as a
datein 3.1, the schemas are correct:
in 3.2, they are not:

Possible Solution
Unsure, tried to figure it out but failed.
Additional Context