|
22 | 22 | use ApiPlatform\JsonSchema\SchemaFactoryAwareInterface; |
23 | 23 | use ApiPlatform\JsonSchema\SchemaFactoryInterface; |
24 | 24 | use ApiPlatform\JsonSchema\SchemaUriPrefixTrait; |
| 25 | +use ApiPlatform\JsonSchema\TypeAwareDefinitionNameFactoryInterface; |
25 | 26 | use ApiPlatform\Metadata\Operation; |
26 | 27 | use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; |
27 | 28 |
|
@@ -136,7 +137,11 @@ public function buildSchema(string $className, string $format = 'jsonld', string |
136 | 137 | $collectionKey = $schema->getItemsDefinitionKey(); |
137 | 138 |
|
138 | 139 | if (!$collectionKey) { |
139 | | - $definitionName = $schema->getRootDefinitionKey() ?? $this->definitionNameFactory->create($className, $format, $inputOrOutputClass, $operation, $serializerContext); |
| 140 | + if ($this->definitionNameFactory instanceof TypeAwareDefinitionNameFactoryInterface) { |
| 141 | + $definitionName = $schema->getRootDefinitionKey() ?? $this->definitionNameFactory->create($className, $format, $inputOrOutputClass, $operation, $serializerContext, $type); |
| 142 | + } else { |
| 143 | + $definitionName = $schema->getRootDefinitionKey() ?? $this->definitionNameFactory->create($className, $format, $inputOrOutputClass, $operation, $serializerContext); |
| 144 | + } |
140 | 145 | $this->decorateItemDefinition($definitionName, $definitions, $prefix, $type, $serializerContext); |
141 | 146 |
|
142 | 147 | if (isset($definitions[$definitionName])) { |
@@ -235,7 +240,11 @@ public function buildSchema(string $className, string $format = 'jsonld', string |
235 | 240 | ]; |
236 | 241 | } |
237 | 242 |
|
238 | | - $definitionName = $this->definitionNameFactory->create($className, $format, $inputOrOutputClass, $operation, $serializerContext); |
| 243 | + if ($this->definitionNameFactory instanceof TypeAwareDefinitionNameFactoryInterface) { |
| 244 | + $definitionName = $this->definitionNameFactory->create($className, $format, $inputOrOutputClass, $operation, $serializerContext, $type); |
| 245 | + } else { |
| 246 | + $definitionName = $this->definitionNameFactory->create($className, $format, $inputOrOutputClass, $operation, $serializerContext); |
| 247 | + } |
239 | 248 | $schema['type'] = 'object'; |
240 | 249 | $schema['description'] = "$definitionName collection."; |
241 | 250 | $schema['allOf'] = [ |
|
0 commit comments