Skip to content

Commit 06df752

Browse files
committed
fix(hydra): inline input definition name
1 parent 21b0c0d commit 06df752

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎src/JsonApi/JsonSchema/SchemaFactory.php‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareI
4646
*/
4747
public const DISABLE_JSON_SCHEMA_SERIALIZER_GROUPS = 'disable_json_schema_serializer_groups';
4848

49-
private const INPUT_SCHEMA_POSTFIX = 'input';
5049
private const COLLECTION_BASE_SCHEMA_NAME = 'JsonApiCollectionBaseSchema';
5150
private const COLLECTION_BASE_SCHEMA_NAME_NO_PAGINATION = 'JsonApiCollectionBaseSchemaNoPagination';
5251

@@ -128,7 +127,10 @@ public function buildSchema(string $className, string $format = 'jsonapi', strin
128127
}
129128

130129
$schema = $this->schemaFactory->buildSchema($className, 'json', $type, $operation, $schema, $jsonApiSerializerContext, $forceCollection);
131-
$definitionName = $this->createDefinitionName($className, $format, $inputOrOutputClass, $operation, $jsonApiSerializerContext, $type);
130+
$definitionName = $this->definitionNameFactory->create($className, $format, $inputOrOutputClass, $operation, $jsonApiSerializerContext + ['schema_type' => $type]);
131+
if (Schema::TYPE_INPUT === $type) {
132+
$definitionName .= '.input';
133+
}
132134
$prefix = $this->getSchemaUriPrefix($schema->getVersion());
133135
$definitions = $schema->getDefinitions();
134136
$collectionKey = $schema->getItemsDefinitionKey();
@@ -390,13 +392,6 @@ private function buildDefinitionPropertiesSchema(string $key, string $className,
390392
] + $included;
391393
}
392394

393-
private function createDefinitionName(string $className, string $format, ?string $inputOrOutputClass, ?Operation $operation, ?array $serializerContext, string $type): string
394-
{
395-
$name = $this->definitionNameFactory->create($className, $format, $inputOrOutputClass, $operation, ($serializerContext ?? []) + ['schema_type' => $type]);
396-
397-
return Schema::TYPE_INPUT === $type ? $name.'.'.self::INPUT_SCHEMA_POSTFIX : $name;
398-
}
399-
400395
private function getRelationship(string $resourceClass, string $property, ?array $serializerContext): ?array
401396
{
402397
$propertyMetadata = $this->propertyMetadataFactory->create($resourceClass, $property, $serializerContext ?? []);

0 commit comments

Comments
 (0)