|  | 
| 16 | 16 | use ApiPlatform\JsonSchema\Metadata\Property\Factory\SchemaPropertyMetadataFactory; | 
| 17 | 17 | use ApiPlatform\JsonSchema\Tests\Fixtures\DummyWithCustomOpenApiContext; | 
| 18 | 18 | use ApiPlatform\JsonSchema\Tests\Fixtures\DummyWithEnum; | 
|  | 19 | +use ApiPlatform\JsonSchema\Tests\Fixtures\DummyWithMixed; | 
| 19 | 20 | use ApiPlatform\JsonSchema\Tests\Fixtures\DummyWithUnionTypeProperty; | 
| 20 | 21 | use ApiPlatform\JsonSchema\Tests\Fixtures\Enum\IntEnumAsIdentifier; | 
| 21 | 22 | use ApiPlatform\Metadata\ApiProperty; | 
| @@ -167,4 +168,37 @@ public function testUnionTypeAnyOfIsArray(): void | 
| 167 | 168 | 
 | 
| 168 | 169 |         $this->assertEquals($expectedSchema, $apiProperty->getSchema()); | 
| 169 | 170 |     } | 
|  | 171 | + | 
|  | 172 | +    public function testMixed(): void | 
|  | 173 | +    { | 
|  | 174 | +        if (!method_exists(PropertyInfoExtractor::class, 'getType')) { // @phpstan-ignore-line symfony/property-info 6.4 is still allowed and this may be true | 
|  | 175 | +            $this->markTestSkipped('This test only supports type-info component'); | 
|  | 176 | +        } | 
|  | 177 | + | 
|  | 178 | +        $resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class); | 
|  | 179 | +        $apiProperty = new ApiProperty(nativeType: Type::mixed()); | 
|  | 180 | +        $decorated = $this->createMock(PropertyMetadataFactoryInterface::class); | 
|  | 181 | +        $decorated->expects($this->once())->method('create')->with(DummyWithMixed::class, 'mixedProperty')->willReturn($apiProperty); | 
|  | 182 | + | 
|  | 183 | +        $schemaPropertyMetadataFactory = new SchemaPropertyMetadataFactory($resourceClassResolver, $decorated); | 
|  | 184 | +        $apiProperty = $schemaPropertyMetadataFactory->create(DummyWithMixed::class, 'mixedProperty'); | 
|  | 185 | + | 
|  | 186 | +        $this->assertEquals([ | 
|  | 187 | +            'type' => ['string', 'null'], | 
|  | 188 | +        ], $apiProperty->getSchema()); | 
|  | 189 | + | 
|  | 190 | +        $apiProperty = new ApiProperty(nativeType: Type::array(Type::mixed())); | 
|  | 191 | +        $decorated = $this->createMock(PropertyMetadataFactoryInterface::class); | 
|  | 192 | +        $decorated->expects($this->once())->method('create')->with(DummyWithMixed::class, 'mixedArrayProperty')->willReturn($apiProperty); | 
|  | 193 | + | 
|  | 194 | +        $schemaPropertyMetadataFactory = new SchemaPropertyMetadataFactory($resourceClassResolver, $decorated); | 
|  | 195 | +        $apiProperty = $schemaPropertyMetadataFactory->create(DummyWithMixed::class, 'mixedArrayProperty'); | 
|  | 196 | + | 
|  | 197 | +        $this->assertEquals([ | 
|  | 198 | +            'type' => 'array', | 
|  | 199 | +            'items' => [ | 
|  | 200 | +                'type' => ['string', 'null'], | 
|  | 201 | +            ], | 
|  | 202 | +        ], $apiProperty->getSchema()); | 
|  | 203 | +    } | 
| 170 | 204 | } | 
0 commit comments