Skip to content

Commit ce297e6

Browse files
Fr13nzzzBastiLu
andauthored
fix(jsonschema): child entity property schema generation (#5988) (#5989)
Subrecource property schemes should be built with the same scheme type than their parent, otherwise this could lead to errors in the generated schemes. fixes #5988 Co-authored-by: Bastien Lutz <[email protected]>
1 parent 1b42894 commit ce297e6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/JsonSchema/SchemaFactory.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ public function buildSchema(string $className, string $format = 'json', string $
139139
$definition['required'][] = $normalizedPropertyName;
140140
}
141141

142-
$this->buildPropertySchema($schema, $definitionName, $normalizedPropertyName, $propertyMetadata, $serializerContext, $format);
142+
$this->buildPropertySchema($schema, $definitionName, $normalizedPropertyName, $propertyMetadata, $serializerContext, $format, $type);
143143
}
144144

145145
return $schema;
146146
}
147147

148-
private function buildPropertySchema(Schema $schema, string $definitionName, string $normalizedPropertyName, ApiProperty $propertyMetadata, array $serializerContext, string $format): void
148+
private function buildPropertySchema(Schema $schema, string $definitionName, string $normalizedPropertyName, ApiProperty $propertyMetadata, array $serializerContext, string $format, string $parentType): void
149149
{
150150
$version = $schema->getVersion();
151151
if (Schema::VERSION_SWAGGER === $version || Schema::VERSION_OPENAPI === $version) {
@@ -216,7 +216,7 @@ private function buildPropertySchema(Schema $schema, string $definitionName, str
216216
continue;
217217
}
218218

219-
$subSchema = $this->buildSchema($className, $format, Schema::TYPE_OUTPUT, null, $subSchema, $serializerContext + [self::FORCE_SUBSCHEMA => true], false);
219+
$subSchema = $this->buildSchema($className, $format, $parentType, null, $subSchema, $serializerContext + [self::FORCE_SUBSCHEMA => true], false);
220220
if ($isCollection) {
221221
$propertySchema['items']['$ref'] = $subSchema['$ref'];
222222
unset($propertySchema['items']['type']);

0 commit comments

Comments
 (0)