@@ -156,4 +156,58 @@ public function testBuildSchemaForOperationWithOverriddenSerializerGroups(): voi
156
156
$ this ->assertArrayHasKey ('type ' , $ definitions [$ rootDefinitionKey ]['properties ' ]['description ' ]);
157
157
$ this ->assertSame ('string ' , $ definitions [$ rootDefinitionKey ]['properties ' ]['description ' ]['type ' ]);
158
158
}
159
+
160
+ public function testBuildSchemaOnlyRef (): void
161
+ {
162
+ $ typeFactoryProphecy = $ this ->prophesize (TypeFactoryInterface::class);
163
+ $ typeFactoryProphecy ->getType (Argument::allOf (
164
+ Argument::type (Type::class),
165
+ Argument::which ('getBuiltinType ' , Type::BUILTIN_TYPE_STRING )
166
+ ), Argument::cetera ())->willReturn ([
167
+ 'type ' => 'string ' ,
168
+ ]);
169
+
170
+ $ resourceMetadataFactoryProphecy = $ this ->prophesize (ResourceMetadataFactoryInterface::class);
171
+ $ resourceMetadataFactoryProphecy ->create (OverriddenOperationDummy::class)->willReturn (new ResourceMetadata ((new \ReflectionClass (OverriddenOperationDummy::class))->getShortName (), null , null , [
172
+ 'put ' => [
173
+ 'normalization_context ' => [
174
+ 'groups ' => 'overridden_operation_dummy_put ' ,
175
+ AbstractNormalizer::ALLOW_EXTRA_ATTRIBUTES => false ,
176
+ ],
177
+ 'validation_groups ' => ['validation_groups_dummy_put ' ],
178
+ ],
179
+ ], [], [
180
+ 'normalization_context ' => [
181
+ 'groups ' => 'overridden_operation_dummy_read ' ,
182
+ ],
183
+ ]));
184
+
185
+ $ serializerGroup = 'overridden_operation_dummy_put ' ;
186
+ $ validationGroups = 'validation_groups_dummy_put ' ;
187
+
188
+ $ propertyNameCollectionFactoryProphecy = $ this ->prophesize (PropertyNameCollectionFactoryInterface::class);
189
+ $ propertyNameCollectionFactoryProphecy ->create (OverriddenOperationDummy::class, Argument::allOf (
190
+ Argument::type ('array ' ),
191
+ Argument::allOf (Argument::withEntry ('serializer_groups ' , [$ serializerGroup ]), Argument::withEntry ('validation_groups ' , [$ validationGroups ]))
192
+ ))->willReturn (new PropertyNameCollection (['alias ' , 'description ' ]));
193
+
194
+ $ propertyMetadataFactoryProphecy = $ this ->prophesize (PropertyMetadataFactoryInterface::class);
195
+ $ propertyMetadataFactoryProphecy ->create (OverriddenOperationDummy::class, 'alias ' , Argument::allOf (
196
+ Argument::type ('array ' ),
197
+ Argument::allOf (Argument::withEntry ('serializer_groups ' , [$ serializerGroup ]), Argument::withEntry ('validation_groups ' , [$ validationGroups ]))
198
+ ))->willReturn (new PropertyMetadata (new Type (Type::BUILTIN_TYPE_STRING ), null , true ));
199
+ $ propertyMetadataFactoryProphecy ->create (OverriddenOperationDummy::class, 'description ' , Argument::allOf (
200
+ Argument::type ('array ' ),
201
+ Argument::allOf (Argument::withEntry ('serializer_groups ' , [$ serializerGroup ]), Argument::withEntry ('validation_groups ' , [$ validationGroups ]))
202
+ ))->willReturn (new PropertyMetadata (new Type (Type::BUILTIN_TYPE_STRING ), null , true ));
203
+
204
+ $ resourceClassResolverProphecy = $ this ->prophesize (ResourceClassResolverInterface::class);
205
+ $ resourceClassResolverProphecy ->isResourceClass (OverriddenOperationDummy::class)->willReturn (true );
206
+
207
+ $ schemaFactory = new SchemaFactory ($ typeFactoryProphecy ->reveal (), $ resourceMetadataFactoryProphecy ->reveal (), $ propertyNameCollectionFactoryProphecy ->reveal (), $ propertyMetadataFactoryProphecy ->reveal (), null , $ resourceClassResolverProphecy ->reveal ());
208
+ $ resultSchema = $ schemaFactory ->buildSchema (OverriddenOperationDummy::class, 'json ' , Schema::TYPE_OUTPUT , OperationType::ITEM , 'put ' , null , [], false , true );
209
+
210
+ $ this ->assertSame ('#/definitions/OverriddenOperationDummy ' , $ resultSchema ['$ref ' ]);
211
+ $ this ->assertCount (0 , $ resultSchema ->getDefinitions ());
212
+ }
159
213
}
0 commit comments