Skip to content

Commit 4691c25

Browse files
committed
fix(ci): fix JsonSchema/Tests/SchemaFactoryTest::testBuildSchemaWithSerializerAttributes()
1 parent 2082645 commit 4691c25

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/JsonSchema/SchemaFactory.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,24 @@ private function buildLegacyPropertySchema(Schema $schema, string $definitionNam
244244
continue;
245245
}
246246

247+
$childSerializerContext = $serializerContext + [self::FORCE_SUBSCHEMA => true, 'gen_id' => $propertyMetadata->getGenId() ?? true];
248+
if (isset($serializerContext[AbstractNormalizer::ATTRIBUTES])) {
249+
$attributes = $serializerContext[AbstractNormalizer::ATTRIBUTES];
250+
if (\is_array($attributes) && \array_key_exists($normalizedPropertyName, $attributes) && \is_array($attributes[$normalizedPropertyName])) {
251+
$childSerializerContext[AbstractNormalizer::ATTRIBUTES] = $attributes[$normalizedPropertyName];
252+
} else {
253+
unset($childSerializerContext[AbstractNormalizer::ATTRIBUTES]);
254+
}
255+
}
256+
247257
$subSchemaFactory = $this->schemaFactory ?: $this;
248258
$subSchema = $subSchemaFactory->buildSchema(
249259
$className,
250260
$format,
251261
$parentType,
252262
null,
253263
$subSchema,
254-
$serializerContext + [self::FORCE_SUBSCHEMA => true, 'gen_id' => $propertyMetadata->getGenId() ?? true],
264+
$childSerializerContext,
255265
false,
256266
);
257267

0 commit comments

Comments
 (0)