@@ -49,4 +49,33 @@ public function testWithCustomOpenApiContext(): void
4949 $ apiProperty = $ schemaPropertyMetadataFactory ->create (DummyWithCustomOpenApiContext::class, 'acme ' );
5050 $ this ->assertEquals ([], $ apiProperty ->getSchema ());
5151 }
52+
53+ public function testWithCustomOpenApiContextWithoutTypeDefinition (): void
54+ {
55+ $ resourceClassResolver = $ this ->createMock (ResourceClassResolverInterface::class);
56+ $ apiProperty = new ApiProperty (
57+ openapiContext: ['description ' => 'My description ' ],
58+ builtinTypes: [new Type (builtinType: 'bool ' )],
59+ );
60+ $ decorated = $ this ->createMock (PropertyMetadataFactoryInterface::class);
61+ $ decorated ->expects ($ this ->once ())->method ('create ' )->with (DummyWithCustomOpenApiContext::class, 'foo ' )->willReturn ($ apiProperty );
62+ $ schemaPropertyMetadataFactory = new SchemaPropertyMetadataFactory ($ resourceClassResolver , $ decorated );
63+ $ apiProperty = $ schemaPropertyMetadataFactory ->create (DummyWithCustomOpenApiContext::class, 'foo ' );
64+ $ this ->assertEquals ([
65+ 'type ' => 'boolean ' ,
66+ ], $ apiProperty ->getSchema ());
67+
68+ $ apiProperty = new ApiProperty (
69+ openapiContext: ['iris ' => 'https://schema.org/Date ' ],
70+ builtinTypes: [new Type (builtinType: 'object ' , class: \DateTimeImmutable::class)],
71+ );
72+ $ decorated = $ this ->createMock (PropertyMetadataFactoryInterface::class);
73+ $ decorated ->expects ($ this ->once ())->method ('create ' )->with (DummyWithCustomOpenApiContext::class, 'bar ' )->willReturn ($ apiProperty );
74+ $ schemaPropertyMetadataFactory = new SchemaPropertyMetadataFactory ($ resourceClassResolver , $ decorated );
75+ $ apiProperty = $ schemaPropertyMetadataFactory ->create (DummyWithCustomOpenApiContext::class, 'bar ' );
76+ $ this ->assertEquals ([
77+ 'type ' => 'string ' ,
78+ 'format ' => 'date-time ' ,
79+ ], $ apiProperty ->getSchema ());
80+ }
5281}
0 commit comments