Skip to content

Commit 00c632b

Browse files
Add schema type in serializer context for schema factory
1 parent c857b52 commit 00c632b

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/Hal/JsonSchema/SchemaFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function buildSchema(string $className, string $format = 'jsonhal', strin
9292

9393
$schema = $this->schemaFactory->buildSchema($className, 'json', $type, $operation, $schema, $serializerContext, $forceCollection);
9494
$definitions = $schema->getDefinitions();
95-
$definitionName = $this->definitionNameFactory->create($className, $format, $className, $operation, $serializerContext);
95+
$definitionName = $this->definitionNameFactory->create($className, $format, $className, $operation, $serializerContext + ['schema_type' => $type]);
9696
$prefix = $this->getSchemaUriPrefix($schema->getVersion());
9797
$collectionKey = $schema->getItemsDefinitionKey();
9898

src/Hydra/JsonSchema/SchemaFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public function buildSchema(string $className, string $format = 'jsonld', string
247247
];
248248
}
249249

250-
$definitionName = $this->definitionNameFactory->create($className, $format, $inputOrOutputClass, $operation, $serializerContext);
250+
$definitionName = $this->definitionNameFactory->create($className, $format, $inputOrOutputClass, $operation, $serializerContext + ['schema_type' => $type]);
251251
$schema['type'] = 'object';
252252
$schema['description'] = "$definitionName collection.";
253253
$schema['allOf'] = [

src/JsonApi/JsonSchema/SchemaFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function buildSchema(string $className, string $format = 'jsonapi', strin
125125
}
126126

127127
$schema = $this->schemaFactory->buildSchema($className, 'json', $type, $operation, $schema, $jsonApiSerializerContext, $forceCollection);
128-
$definitionName = $this->definitionNameFactory->create($inputOrOutputClass, $format, $className, $operation, $jsonApiSerializerContext);
128+
$definitionName = $this->definitionNameFactory->create($inputOrOutputClass, $format, $className, $operation, $jsonApiSerializerContext + ['schema_type' => $type]);
129129
$prefix = $this->getSchemaUriPrefix($schema->getVersion());
130130
$definitions = $schema->getDefinitions();
131131
$collectionKey = $schema->getItemsDefinitionKey();
@@ -300,7 +300,7 @@ private function buildDefinitionPropertiesSchema(string $key, string $className,
300300
$operation = $this->findOperation($relatedClassName, $type, null, $serializerContext);
301301
$inputOrOutputClass = $this->findOutputClass($relatedClassName, $type, $operation, $serializerContext);
302302
$serializerContext ??= $this->getSerializerContext($operation, $type);
303-
$definitionName = $this->definitionNameFactory->create($relatedClassName, $format, $inputOrOutputClass, $operation, $serializerContext);
303+
$definitionName = $this->definitionNameFactory->create($relatedClassName, $format, $inputOrOutputClass, $operation, $serializerContext + ['schema_type' => $type]);
304304

305305
// to avoid recursion
306306
if ($this->builtSchema[$definitionName] ?? false) {

src/JsonSchema/SchemaFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function buildSchema(string $className, string $format = 'json', string $
9797
$isJsonMergePatch => 'merge-patch+json',
9898
};
9999

100-
$definitionName = $this->definitionNameFactory->create($className, $definitionFormat, $inputOrOutputClass, $operation, $serializerContext);
100+
$definitionName = $this->definitionNameFactory->create($className, $definitionFormat, $inputOrOutputClass, $operation, $serializerContext + ['schema_type' => $type]);
101101

102102
if (!isset($schema['$ref']) && !isset($schema['type'])) {
103103
$ref = $this->getSchemaUriPrefix($version).$definitionName;

0 commit comments

Comments
 (0)